You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider Geometry of Turns for Instruction Sign calculation #999
Currently the sign for turn instructions is calculated using the second node (or the adjacent node as fallback) of the way geometry. This works very good for straight streets.
If the street we are turning onto is crooked/bend this does not work that good anymore. This mostly happens for *_links, that start as a slight turn, but start to bend after a very short time. On the other hand, some turns that look like a continue, are considered as a turn.
I played around with the code a little, but couldn't come up with a good idea to solve this, yet. My first idea was to use a point of the edge geometry that is about 50-100m from the crossing away, but as it turns out, this is usually the second point anyway, so this is not really an improvement...
I did some more investigation here. I think "keeps" already improved the situation (introduced in #1075). But it's not fixed, as many slight turns, should be actual turns.
In a lot of cases, using the 3rd point instead of the 2nd point, can make the instructions worse than better. There are a lot of cases like:
When you take the 3rd point in these cases, an actual turn is only a keep or slight turn, because the turning angle actually reduced and was not increased.
If we look at junctions between bigger roads, there are cases like:
Usually these roads have turn lanes, therefore a keep right/left instruction is not wrong, But a an actual turn might be the better option and easier to understand for most users in this situation.
So probably we should only run a different handling on roads from tertiary or secondary up?
An alternative approach to using the 3rd or even 4th point of a way would be to select the first x points that are within y meters of the junction, and use the point with the largest angle. But the angle calculation uses atan, which is slow to calculate and would probably hurt the performance too much.
If we look at junctions between bigger roads, there are cases like:
It seems both links are identical (?)
In a lot of cases, using the 3rd point instead of the 2nd point, can make the instructions worse than better. ... use the point with the largest angle.
I think this sounds like a reasonable solution or as you also suggested consider the road_class (or even max_speed) in this calculation. Because if you approach a "slight-turn" with high speed it likely means a real "turn" for you ... but just wild guessing here. Probably we also need much more tests.
which is slow to calculate and would probably hurt the performance too much
We shouldn't care that much about performance in these cases. I think quality should be more important here. Additionally I think there might be thousands of points but only dozens of "instruction candidates" to calculate? Or at least we should not concentrate yet on performance and do the reduction to these "instruction candidates" if required but later.
^ that split is wrongly mapped - but still should give an instruction.
The motorway-link should either split into 2 motorways or 2 motorway-links to make it clear it is a fork.
When the motorway splits into motorway and motorway-link (not this case) router can (and most do, including osmand) interpret a link as a motorway exit and give no instruction on continuing on motorway (which is technically correct).
In your case the motorway-link splits into motorway-link + motorway and a router-x can interpret staying on link as no instruction (which can also be considered as logical) and treat the different type way as exit, or can threat it as a fork (keep left/right) as the way splits into no-lower-class ways.
Activity
boldtrn commentedon Nov 14, 2019
I did some more investigation here. I think "keeps" already improved the situation (introduced in #1075). But it's not fixed, as many slight turns, should be actual turns.
In a lot of cases, using the 3rd point instead of the 2nd point, can make the instructions worse than better. There are a lot of cases like:
When you take the 3rd point in these cases, an actual turn is only a keep or slight turn, because the turning angle actually reduced and was not increased.
If we look at junctions between bigger roads, there are cases like:
Usually these roads have turn lanes, therefore a keep right/left instruction is not wrong, But a an actual turn might be the better option and easier to understand for most users in this situation.
So probably we should only run a different handling on roads from tertiary or secondary up?
An alternative approach to using the 3rd or even 4th point of a way would be to select the first x points that are within y meters of the junction, and use the point with the largest angle. But the angle calculation uses atan, which is slow to calculate and would probably hurt the performance too much.
karussell commentedon Nov 14, 2019
It seems both links are identical (?)
I think this sounds like a reasonable solution or as you also suggested consider the road_class (or even max_speed) in this calculation. Because if you approach a "slight-turn" with high speed it likely means a real "turn" for you ... but just wild guessing here. Probably we also need much more tests.
We shouldn't care that much about performance in these cases. I think quality should be more important here. Additionally I think there might be thousands of points but only dozens of "instruction candidates" to calculate? Or at least we should not concentrate yet on performance and do the reduction to these "instruction candidates" if required but later.
BTW: I found a case where no turn is displayed at all, although it is a pretty clear T-junction in reality: https://graphhopper.com/maps/?point=51.488492%2C14.368315&point=51.488892%2C14.37016
boldtrn commentedon Nov 15, 2019
Oh, sorry, I updated the second example above to this junction: https://graphhopper.com/maps/?point=48.694377%2C9.801967&point=48.695574%2C9.802176
Absolutely, yes :).
Yes, I think this could help indeed quite a lot.
Yes, indeed. It shouldn't bee too many atan calculations, but my guess is that we will see a negative perfomance impact for CH with instructions.
I will give this approach a go and see how the results look like.
karussell commentedon Nov 19, 2021
I found another case where it is crucial to create a turn instruction (where we currently don't): https://graphhopper.com/maps/?point=51.1317%2C13.751793&point=51.138863%2C13.755913
boldtrn commentedon Nov 19, 2021
Good catch 👍 - this looks tricky to fix but in this case we should show an instruction.
vmicho commentedon Jun 28, 2026
^ that split is wrongly mapped - but still should give an instruction.
The motorway-link should either split into 2 motorways or 2 motorway-links to make it clear it is a fork.
When the motorway splits into motorway and motorway-link (not this case) router can (and most do, including osmand) interpret a link as a motorway exit and give no instruction on continuing on motorway (which is technically correct).
In your case the motorway-link splits into motorway-link + motorway and a router-x can interpret staying on link as no instruction (which can also be considered as logical) and treat the different type way as exit, or can threat it as a fork (keep left/right) as the way splits into no-lower-class ways.