Skip to content

EN—Routing

Antonin Del Fabbro edited this page Feb 4, 2024 · 1 revision

I started from the routing.xml file used by OsmAnd for all its default profiles and proposed here

I kept only the part concerning the car that I adapted for 3 uses

  • heavy motorcycle (very road tires)
  • light "trail" motorcycle (50/50 tires)
  • enduro motorcycle

to follow the path categories defined in the display style.

among the important parameters, <attribute name="heuristicCoefficient" value="7.0" /> plays a lot on the speed of calculation of a route on the one hand and on its "compliance" with the criteria expressed then (of course it's inversely proportional!!!
the higher it is, the less "accurate" the results are in relation to an ideal time/distance between 2 points.)
it's quite theoretical and in my tests I haven't found anything really "shocking" when it comes to the choice of paths (which interests me in the first place)
here the value 7.0 presents a good compromise speed of calculation/choice of paths, you can experiment with other values ​​at will.

the "routing" part

is in this block which includes all the other blocks described below.

<routingProfile name="gros_trail" baseProfile="car" restrictionsAware="true" minSpeed="1" defaultSpeed="30.0" maxSpeed="90.0" sharpTurn="" slightTurn="" roundaboutTurn="" followSpeedLimitations="false" onewayAware ="true">
.....
</routingProfile>

at the beginning of this block the options in the "guidance" menu of the profile to which this routing will be assigned, as here "no paths" of the big trail routing

<parameter id="avoid_track" name="no tracks" description="avoid tracks" type="boolean" default="false"/>

which translates like this in use
no_paths

and reference to the "avoid_track" block of the "priority" block (see below)

<if param="avoid_track">
<select value="0" t="ford" v="yes"/>
<select value="0" t="surface" v="mud"/>
<select value="0" t="surface" v="grass"/>
<select value="0" t="surface" v="sand"/>
<select value="0" t="surface" v="dirt"/>
<select value="0" t="surface" v="earth"/>
<select value="0" t="surface" v="unpaved"/>
<select value="0" t="surface" v="ground"/>
<select value="0" t="tracktype" v="grade5"/>
<select value="0" t="tracktype" v="grade4"/>
<select value="0" t="surface" v="compacted"/>
<select value="0" t="surface" v="gravel"/>
<select value="0" t="surface" v="pebblestone"/>
<select value="0" t="surface" v="paved"/>
<select value="0" t="surface" v="paving_stones"/>
<select value="0" t="tracktype" v="grade3"/>
<select value="0.2" t="surface" v="fine_gravel"/>
<select value="1" t="surface" v="asphalt"/>
<select value="0.8" t="surface" v="concrete"/>
<select value="0" t="tracktype" v="grade2"/>
<select value="0.3" t="tracktype" v="grade1"/>
<select value="0" t="highway" v="track"/><!--paths without tags-->
</if>

where each value="0" disallows use for routing.
it's quite paradoxical in a routing dedicated to paths to only want to drive on the road..
but following the request of a user who travels a lot and who found that my routing made him go through very small magnificent roads that no other GPS ever borrows, he asked me to make this option to be able to go through these roads without taking paths in case of fatigue on his part, the most surprising thing is that it works by sometimes taking very short stretches of paths otherwise the calculation will fail.

the "access" block

 <way attribute="access">
<select value="-1" t="osmand_change" v="delete"/>
<select value="-1" t="build" v="yes"/>
<select value="-1" t="smoothness" v="impassable"/>
<select value="-1" t="highway" v="path"/>

defined by yes (1) or no (-1) access and will not be taken into account for guidance. (the ifs allow a choice relative to an option defined at the beginning)

the "oneway" block

is taken from the default OsmAnd, unless you want to drive against the direction, no need to modify it.

the "speed" block

is of little use in off-road use, I left average values ​​based on my experience (you can modify them to see)

the "priority" block

is the most important of all for the choice of paths with its sub-blocks

first the definition of the "routes" with for each element a number between 0 and 1 and beyond 1, if "1" the routing calculation engine does not apply a penalty, if 0 the engine will avoid this element, if greater than 1 the element will be preferred (I refer you to the help included in the OsmAnd routing file)
here for "big trail"

<select value="0.1" t="highway" v="motorway"/>
<select value="0.1" t="highway" v="motorway_link"/>
<select value="0.15" t="highway" v="trunk"/>
<select value="0.15" t="highway" v="trunk_link"/>
<select value="0.15" t="highway" v="primary"/>
<select value="0.15" t="highway" v="primary_link"/>
<select value="0.2" t="highway" v="secondary"/>
<select value="0.2" t="highway" v="secondary_link"/>
<select value="0.25" t="highway" v="tertiary"/>
<select value="0.25" t="highway" v="tertiary_link"/>
<select value="0.3" t="highway" v="unclassified"/>
<select value="0.3" t="highway" v="road"/>
<select value="0.3" t="highway" v="service"/>
<select value="0.3" t="highway" v="residential"/>
<select value="0.1" t="highway" v="living_street"/>

<select value="0.1" t="ford" v="yes"/>
<select value="0.05" t="surface" v="mud"/>
<select value="0.05" t="surface" v="grass"/>
<select value="0.05" t="surface" v="sand"/>
<select value="0.1" t="surface" v="dirt"/>
<select value="0.1" t="surface" v="earth"/>
<select value="0.1" t="surface" v="unpaved"/>
<select value="0.1" t="surface" v="ground"/>
<select value="0.1" t="tracktype" v="grade5"/>
<select value="0.2" t="tracktype" v="grade4"/>
<select value="2.8" t="surface" v="compacted"/>
<select value="2.8" t="surface" v="gravel"/>
<select value="2.8" t="surface" v="pebblestone"/>
<select value="2.8" t="surface" v="paved"/>
<select value="2.8" t="surface" v="paving_stones"/>
<select value="2.8" t="tracktype" v="grade3"/>
<select value="3" t="surface" v="fine_gravel"/>
<select value="3" t="surface" v="asphalt"/>
<select value="3" t="surface" v="concrete"/>
<select value="3" t="tracktype" v="grade2"/>
<select value="3" t="tracktype" v="grade1"/>
<select value="0.1" t="highway" v="track"/><!--paths without tags-->

the whole hierarchy is defined here the "grade1" have the highest number when a secondary road at "0.2"
interspersed are the "if" in relation to the options proposed in the guidance options of the profile (according to what they modify, the order is important otherwise the values ​​will not be applied, they apply a times in the order in which the tag is chosen (a path which is both mud and grade1 which is inconsistent but often present in osm will be processed only once with the first tag called, here I advise you to put "mud" for mud first ^^)

the "obstacle" block

prohibits or penalizes according to elements present in osm and listed in the block

the "penalty_transition" block

not of interest for our use (see doc in OsmAnd's routing.xml file)