Put the original OSM tags on the legs from the route API call
Hi,
For route rendering purposes, I would like to have access to the original OSM tags on the legs array returned by the route API call. The legs could therefore be rendered according to their highway tag value for example.
My first thought was to use the mode property and to give it the highway value but this looks to be a fixed list: https://github.com/Project-OSRM/osrm-backend/blob/master/include/extractor/travel_mode.hpp#L57
Is there any way to achieve this?
@fredericbonifas No, there is no general purpose way to achieve this. OSRM does not index all the OSM data after pre-processing, we only keep what we need. Storing everything would greatly increase memory needs.
In the past, some folks have tried encoding various OSM tags in the name property, but if you want to keep reasonable quality turn-by-turn instructions, be wary of this approach - the name is used as a heuristic to detect things like obvious turns and differentiate between forks/turns.
The "right" way to do this is something like:
- Use the
annotations=nodesparameter to retrieve the OSM node IDs along the route. - Use something like https://github.com/mapbox/route-annotator to query the OSM tags along that sequence of nodes.
This has come up a few times and I think we've basically agreed that we will never build this feature into OSRM itself.
Thank you for the answer @danpat For the record, related to #1342
I finally managed to add this information through classes, so that one step in the answer looks like this:
"intersections":[
{
"classes":[
"sidewalk"
],
"location":[
1.447344,
43.585469
],
"bearings":[
164
],
"entry":[
true
],
"out":0
}
],
"geometry":"ex_iG{tyGFC",
"mode":"walking",
"duration":3,
"maneuver":{
"bearing_after":164,
"location":[
1.447344,
43.585469
],
"bearing_before":0,
"type":"depart"
},
"weight":4.2,
"distance":4.3,
"name":""
}
Does this look acceptable to you @danpat ?