Project-OSRM / osrm-backend

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

Staggered junctions #5167

Open bjtaylor1 opened 6 years ago

bjtaylor1 commented 6 years ago

Hello,

I have refined a lua profile ( https://github.com/bjtaylor1/osrmbuilder/blob/master/optimum.lua#L32 ) to incur a penalty for turning onto a primary or trunk in process_turn by the use of source_highway_turn_classification and target_highway_turn_classification. I have also assigned a higher weight to primaries and trunks in process_way. This has the effect that if I do a long distance route, it will try to stay off primaries and trunks where it can, but if it 'has to' use one, it will stay on it, rather than keep coming off and on again, e.g.: http://www.gpxeditor.co.uk/routes2/users/BenTaylor/offandonagain Avoiding primaries and trunks, but at the same time not trying to keep going off and on again once you're on one, is something I'm really pleased the algorithm has managed to achieve, so I think I want to stick with some variant of that.

However it has an annoying, but completely understandable, side effect, which is in instances where there is a 'staggered crossing' - where a minor road crosses a primary/trunk, but the crossing due to its shape is mapped by two nodes rather than one, so you are actually turning onto the primary but straight off it again. With a penalty for turning off a non-primary/trunk onto a primary/trunk high enough to avoid the 'off and on again' phenomenon indicated above, I get routes like this: http://www.gpxeditor.co.uk/routes2/users/BenTaylor/avoidsstaggered For instance coming up the B6030, I have to cross Rock Hill, which is a primary, but I don't really want to incur a penalty for turning 'onto' it: in reality, I can pull out straight into the right turn filter lane. https://goo.gl/maps/pqwkXUpEKcD2

Now I know it could be argued that in some scenarios, going off a primary then onto it again could be not too bad, hence an argument for reducing the 'onto primary' penalty, and there is an argument that 'crossing' a primary on a staggered crossing should incur a penalty. But it seems the ideal penalty for avoiding 'off then on again' causes it to make far too much effort to avoid staggered crossings.

My thought was that I could preprocess by adding in a supplementary way for the staggered junction, however this would rely on the two sides of the road that crosses having the same reference/name, e.g. B6030, this would involve something like finding all pairs of nodes on primaries which are connected to different ways but of the same name/ref, that are within say 50 metres of each other, and inserting a new way which doesn't incur a turn penalty. (I also definitely need to ensure it won't create a false bridge at points like this https://goo.gl/maps/FbmJ5tp2pMt where you can't cross!)

Can anyone suggest either a better way of accomplishing this, or how I might go about my preprocessing - e.g. what tool(s) could I use, etc.

Thanks

danpat commented 6 years ago

I don't have an immediate solution to this, but I do have some thoughts.

This seems like an example of what we've been calling "segregated intersections" - places where the shape of the routing graph diverges from the reality of driving. We see it a lot in large multi-lane intersections - often, people will map many small ways that represent paths of travel through the intersection, which results in many nodes in our graph, but a human on the ground really only perceives it as a single maneuver/turn.

Our turn-by-turn code currently has some smarts around this - if two "maneuvers" in the routing graph are very close, we will collapse them into a single instruction.

In the scenario you've described above, it looks like it would make sense to automatically collapse the stagger into a single maneuver (likely "continue straight"), and thus, not apply the primary->trunk->primary penalty at all.

Now for the bad news: segregated intersection collapsing only happens post-routing currently. The code needs to know the path being traversed in order to decide whether to collapse multiple maneuvers together.

Turn penalties are applied during pre-processing to every routing graph edge somewhat naively. In an ideal world, I think we would integrate the segregated intersection logic with the turn penalty calculation, so that we were applying penalties to the human-perceived maneuvers, rather than strictly on the shape of the routing graph. If we did this, then I think the scenario you've described would be magically solved. Unfortunately, we don't do it this way, and it'd be a pretty big re-arrangement of things to achieve it.

1ec5 commented 5 years ago

By the way, #2738 does collapse staggered intersections. However, this feature is limited to when the intersection nodes are 3 meters apart or less, which is adequate for quiet residential roads but not for larger roads.

bjtaylor1 commented 5 years ago

Interesting, thanks.

On Wed, 19 Dec 2018, 2:42 am Minh Nguyễn <notifications@github.com wrote:

By the way, #2738 https://github.com/Project-OSRM/osrm-backend/pull/2738 does collapse staggered intersections. However, this feature is limited to when the intersection nodes are 3 meters apart or less, which is adequate for quiet residential roads but not for larger roads.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Project-OSRM/osrm-backend/issues/5167#issuecomment-448449273, or mute the thread https://github.com/notifications/unsubscribe-auth/AEQ1W7rxu6vXWkmYnomgaNH_gnuZ-t0Mks5u6aeegaJpZM4V788l .

github-actions[bot] commented 2 months ago

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