Tweaking the OSM-And routing engine
Pieter Vander Vennet님이 English로 2017년 11월 8일에 게시함. 최근 2019년 1월 12일에 업데이트됨.After some experimenting and help from the Belgian OSM Community, I figured out how to tweak the parameters for the routing engine and steer the navigation process. It seemed as if the technical documentation was missing, so lets write it here.
The parameter file: routing.xml
All parameters for the routing file are stored in a single XML.
You can find this XML on the OSMAnd github. Head over there, and download it. EDIT: By now, all the documentation has been included upstream. Everything you can read here, you an also find in the github routing.xml file. This diary entry can still serve as a gentle introduction.
This document should be placed in a place where OsmAnd will find it. As I chose ‘external storage’ to store my maps (settings
-> general settings
-> Data Storage Folder
(under miscellaneous title), adding this custom routing is easy.
Plug your phone in your computer and go to the path /sdcard/Android/data/net.osmand.plus/files
. Copy routing.xml
over.
Reading the parameter file
routing.xml
is actually documented quite good! Read the docs there to get some general idea.
Adding an option to a profile
The parameters are split per profile. I edited the bicycle profile, as that is what I use most (also see my previous diary entry).
Over there, add a toggle, e.g., if you want to avoid sett surfaces:
<parameter id="avoid_sett" name="Strongly prefer asphalt and paving stones" description="Tries to route around sett and cobblestone, ideal if riding with a cycling cart" type="boolean"/>
The id
is the name you’ll use in if-statements, the name
is what shows up in OSMAnd. Save the file as described above and restart OsmAnd. Start navigation to somewhere. If you click the settings (the cogwheel on the bottom when starting navigation), your new parameter should show up!
Tweaking weights
Routing considers three major aspects:
- access
- speed
- priority
Each of those aspects has its own section in the xml; you can’t miss them.
Access
Access deduces if this road can be used or not. This is very hard: yes or no. If you want to create a profile to cycling with your toddler in the cart, and that toddler wakes up from the sett stones, you can add the following to avoid a condition in all cases:
<select value="-1" t="surface" v="sett"/> -- never ever enter a set road
Of course, you might want to avoid unknown surfaces too:
<select value="-1" /> -- Default: no access
<select value="1" t="surface"/> -- only if a surface is known, allow access
And if you mix in the toggle, you’ll get:
<if param="avoid_sett">
<select value="-1" t="surface" v="sett"/>
</if>
Speed
The other aspects are tweaked similarly:
Speed is the maximal practical speed on a certain road. For example, if sett slows you down to 5 km/h; then you can tell the navigation:
<select value="5" t="surface" v="sett">
This is relative to other speeds. The default routing takes a default speed of 14.5
for cycling, so this would be way slower.
Priority
Priority is the preference of a road. If two routes are equal, the route with the highest priority is taken. However, as I modified both speed
and priority
in a similar way, it is hard to state the differences.
A sample use case
This custom routing can be tailored for your needs. See my other diary entry as an example and for the routes taken.
My custom routing.xml
avoiding sett can be found here; the radical hiking by Joost Schouppe is over here.
토론
2017년 11월 9일 17:00에 giggls님의 의견
It is also possible to use external backend like brouter.
2017년 11월 9일 17:57에 Pieter Vander Vennet님의 의견
I have no idea, I only tried this with OsmAnd, as that is what I use…
2017년 11월 9일 18:06에 giggls님의 의견
Here is a manual on how to enable brouter in osmand (sorry German only) https://blog.natenom.com/2016/08/brouter-bringt-osmand-bei-dass-die-welt-nicht-flach-ist/
2017년 11월 10일 12:53에 Pieter Vander Vennet님의 의견
Hey,
I have no experience with BRouter. Perhaps drop them an email and ask about it?
Or perhaps just test it? Testing can be done relatively easily by hard blocking a road.
Also, I have no clue on how to encode height differences.
2017년 11월 10일 12:58에 giggls님의 의견
It was a sugesstion (by me) for people who want to do cycle routing to give brouter a try not a question.
2017년 11월 26일 07:58에 CartoCharles님의 의견
Thank you for the lightening. I was looking for a way to reduce the speed of the bicycle profile to get better ETA, it should be the solution and it brings a lot of tweak possibility.
I wonder if it is possible with a toggle to privilege or avoid some specific streets with there names. It could be fun in some cities to create tourism custom profiles.
2017년 11월 27일 12:50에 Pieter Vander Vennet님의 의견
Hey mygeomatic,
This should be possible; introduce a parameter as described, and use
<select value="..." t="name" v="Street Name">
2017년 11월 27일 17:02에 CartoCharles님의 의견
Thank you Pieter, I’m looking forward to try it.
2019년 1월 4일 19:45에 joost schouppe님의 의견
The link to your custom routing XML is broken. My playthings are here: https://github.com/pietervdvn/pietervdvn.github.io/blob/master/routing_radical_hiking.xml Includes “prefer cycle routes when driving by car” (because they tend to be scenic and you want to drive slow), “prefer country roads” (because you are just cruising and only want to get to your destination eventually) and “radical hiking” (which will make detours to allow for as much paths as possible)
2019년 1월 12일 16:53에 Pieter Vander Vennet님의 의견
@joost: thx, I’ve finally found time to fix the links.