Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#5167·osrm-backend

Staggered junctions

Author: bjtaylor1Created Aug 14, 2018Updated Aug 5, 2026

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

Source: Project-OSRM/osrm-backend

View original on GitHubView discussion on GitHub