Roundabout Turn_angle seems inconsistent on many roundabouts

Im trying to work out if the inconsistencies im noting with roundabout turn_angle’s are due to OSM, or the calculation I’m using to convert is

turnAngle=Math.toDegrees((double)rName.getInstructions().get(i).getExtraInfoJSON().get(“turn_angle”));
This works perfectly for most roundabouts, but not all.
Here’s some examples
green icon is start , red is finish
TitleBar has Raw Angle and the conversion
Country is New Zealand, drive on Left

at this roundabout


doing a 180 turn around the roundabout results in a turn_angle : 50.99, raw value 0.89

a 90 degree turn to the left at the same roundabout results in turn_angle151.83, raw value 2.65

(should be ~90)

a straight through pass has a turn angle of 227 degrees, raw value 3.96

a 90 degree turn at the same roundabout from the opposing direction results in a 330 degree angle , raw 5.77

a straight through pass from opposing direction is 229

At another roundabout just a few hundred meters away the problem does not occur
this is https://www.openstreetmap.org/#map=19/-37.77270/175.29353
the turn angles are correct, from all directions





and still correct from another direction

there are several other roundabouts that calculate incorrectly
eg https://www.openstreetmap.org/#map=19/-37.78532/175.27147

240 deg should be ~180
152 deg should be ~45

Any ideas why such an inconsistency should occur ?
edit=>
On some of the roundabouts I notice the turn_angle is completely missing and the clockwise value is 2, normally 1, however that’s rare and does not apply to the examples I provided.

This could be one or more bugs combined with some data issues. Maybe you have some time to investigate it? See also the following related issues:



OK, I’ll look into it and see what I can find. Should be a good learning experience too.

1 Like

Peter, I think I have found the source of the issue but am unable to trial a fix
How does one edit “InstructionsFromEdges” when the code is read only, I’m probably looking at decompiled byte code?
However.
The angle that is returned isn’t actually incorrect,
The issue is the feeder roads onto and off the roundabout not being straight, if these are split into a Y (something I notice google maps routes don’t do) it causes the angle of the first and last nodes to be quite a few degrees out. It’s an OSM issue and probably not an easy one to fix.

I wondered if we could use some of the nodes prior and after, so we get a better sense of the initial approach and the eventual exit angle, which I imagine we would need to look back as far as 10m or 4 nodes (whichever comes first)
The Singapore error I can’t emulate here, but I think that’s because the feeder road on that example has several nodes that turn left before the roundabout proper starts turning right.
I notice here that on clockwise roundabouts with a relatively sharp left turn generate an unknown direction “2”.
Should this be raised as a new issue ,or added as a consideration to Nov12 " A new instruction to improve Navigating Roundabouts"

You would need to change this in GraphHopper itself. If you can provide a small map area where the code is wrong (and the data fine) we can try to create a test for this and later fix it.

I wondered if we could use some of the nodes prior and after, so we get a better sense of the initial approach and the eventual exit angle, which I imagine we would need to look back as far as 10m or 4 nodes (whichever comes first)

Yeah, something like this is planned: https://github.com/graphhopper/graphhopper/issues/999

I notice here that on clockwise roundabouts with a relatively sharp left turn generate an unknown direction “2”.

What do you mean here? Do you mean the sign==2?

Haven’t forgotten about this, I’ll do it over weekend

Find below summary of errors

  1. getExtraInfoJSON().containsKey(“turn_angle”) is empty
    clockwise = 2
    image


    https://www.openstreetmap.org/directions?engine=graphhopper_car&route=-37.78548%2C175.27292%3B-37.78440%2C175.27253#map=19/-37.78513/175.27214
    The turn_angle is populated when start and finish points are swapped

  2. Turn angle polluted by angle of feeder roads
    turn angle is ::: 242.36


    https://www.openstreetmap.org/directions?engine=graphhopper_car&route=-37.78249%2C175.25232%3B-37.78299%2C175.25333

similar example


I’ve also created two examples here of NON-ROUNDABOUT turn instructions which are also distorted/affected by angles on road joins. These are both at the same intersection





and finally

note the "slight left onto terapa straight here


Powered by Discourse