Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.21k stars 3.29k forks source link

[Q] Small components (is_small) in profiles #6198

Open dooley opened 2 years ago

dooley commented 2 years ago

Is there a way to remove all small components from routing graph for all nearest/table/... requests?

Now and then we see results, where the matching coordinates are linked to routing islands, which made our solutions fail (very automated jobs)

Bildschirmfoto vom 2022-01-21 15-12-51 .

danpat commented 2 years ago

Small components are decided at data processing time - you can use osrm-extract --small-component-size 0 to prevent any edges being marked as individual small components. Note that this will likely lead to an increase in NoRoute results for route requests, as OSRM will simply snap to the nearest edge then try to route. In a table request, this will result in null entries.

dooley commented 2 years ago

This will lead to possible problems later in our toolchain. Do we have access to the attribute "is_small" for a way in lua?

Where can i find which elements in way/result-objects are available in the lua, so i can print the values?

danpat commented 2 years ago

@dooley well, you can't have your cake and eat it too. If the overall goal is to reduce NoRoutes, and you are less sensitive to accuracy, you can try increasing the small component limit - it defaults to 1000.

The way snapping works in OSRM is as follows:

  1. All input coordinates are snapped to the nearest edge, and if that edge is on a flagged small component, they're also snapped to the nearest edge that is not a small component. This second snap point could be a long way away, depending on the topology.
  2. Once all coordinates are snapped, we run a scan over the snapped points. If they're all on the same small component, then we use that. If there is a mix, then we use the snap that was not a flagged small component.

The idea here is that if you drop one coordinate near a disconnected, say, park, we'll shift the coordinate a bit so it's routable to the rest and you'll get results.

One downside to this is that for some situations, you might actually want a NoRoute - like if a point is dropped on an island that is not actually connected, you probably don't want the coordinate shifted many miles just so it becomes routable.

By default, isolated regions that have <1000 nodes will be flagged as small components. If a region is isolated from the network at large, but has 1001 nodes, it won't be flagged as small, and will be used in step (1) above as the "not small component" snapping candidate.

By increasing the small component size limit, you'll start to flag those larger areas as "small components", and this will cause the snapping logic to likely not snap to them if other points in your request lie elsewhere.

There's a limit to this - we picked 1000 because it's generally larger than most isolated regions - they tend to be small. It sounds like perhaps you're encountering regions of disconnect that are >1000 edges in size. This seems odd within the general road network, there should be very very few of these - are you dealing with extracts from OSM where perhaps you've cut off portions near the border?

github-actions[bot] commented 2 weeks ago

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.