valhalla / valhalla

Open Source Routing Engine for OpenStreetMap
https://valhalla.github.io/valhalla/
Other
4.51k stars 682 forks source link

/trace_attributes returning [] vs error #3529

Closed kungfu303 closed 2 years ago

kungfu303 commented 2 years ago

I noticed that for certain payloads, I get a JSON output of calling /trace_attributes that involves an empty list of edges. Other times, I receive an error (444) saying that "Map Match algorithm failed to find path:walk_or_snap algorithm failed to snap the shape points to the correct shape."

Is the difference that in the former, the cause for no edges might be because of a reason other than the map matching service failing (such as bad user input)? What if my input was correct -- does that mean that if the map matching fails, it could produce either type of response (the former empty edge list or the latter 444 error)? Just need to clarify this so I can prepare for it and handle it correctly in my application if this situation occurs where /trace_attributes does not return out a map matched list of coordinates.

kevinkreiser commented 2 years ago

The best way to find out is to post example requests so we can see what the code is doing exactly

kungfu303 commented 2 years ago

Sure! This was my request payload that produced the 444 error:

{"shape":[{"lat":41.824749,"lon":-71.400676}, {"lat":41.824533, "lon":-71.400873}, {"lat":41.824513,"lon":-71.401114}, {"lat":41.824733, "lon":-71.401517}, {"lat":41.824553, "lon":-71.401817}],"costing":"bicycle","shape_match":"walk_or_snap","filters":{"attributes":["shape","edge.begin_shape_index","edge.end_shape_index","edge.names"],"action":"include"}}

It is because the locations are on footway edges, so the bicycling costing doesn't know of these edges (I would assume). If I change the costing to "pedestrian", it produces a list of edges. Is there a recommended way to ask the service to first try a certain costing, like bicycle, and then try a different one, like pedestrian, if it can't find any edges?

kevinkreiser commented 2 years ago

yeah we have options to allow the costing to "ignore_access" which means allow bikes to use edges in the graph that arent marked with bike access.

{"shape":[{"lat":41.824749,"lon":-71.400676}, {"lat":41.824533, "lon":-71.400873}, {"lat":41.824513,"lon":-71.401114}, {"lat":41.824733, "lon":-71.401517}, {"lat":41.824553, "lon":-71.401817}],"costing":"bicycle","costing_options":{"bicycle":{"ignore_access":true}},"shape_match":"walk_or_snap","filters":{"attributes":["shape","edge.begin_shape_index","edge.end_shape_index","edge.names"],"action":"include"}}

does that work for you, with special attention on this part "costing_options":{"bicycle":{"ignore_access":true}}, apologies it seems i failed to document these "hidden" features :smile: