-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
osrm-extract assert triggering on guidance intersection handler #6218
Comments
6dp is already giving us sub-10cm precision, so it might be the angle calculation code that needs tweaking instead. Nevertheless, OSM stores coordinates to 7dp, so it would be beneficial to match it within OSRM to ensure any geometric errors aren't due to the precision loss during import. |
After further investigation, the issue is indeed in the angle calculation code. The 7dp fix works by accident. The problem occurs because the intersection in question includes a path that overlaps with the intersection. https://www.openstreetmap.org/way/376473222 Here is the minimal test case that triggers the assertion
|
This is what OSRM is seeing at the intersection. Consider the turns for someone travelling south to the intersection (bearing 180°). The initial outgoing bearings for each turn are as expected: The outgoing bearings are adjusted. The logic is complicated, but for footpaths it will consider the path bearing 10 meters from the intersection. In the case of the elevator path, this is now the other side of the intersection, so the bearing is flipped. Furthermore, it's viewed as a u-turn. Because of this we discard the real u-turn and no longer consider it in our calculations. The turn angles are then calculated from the perceived bearings. This can be viewed as the angle between the incoming bearing path and the outgoing bearing path, extended from the intersection node. Angles are then adjusted. Again there is some logic that tries to fix edge-cases. In this case however, the elevator path is adjusted back to 180°, because the initial bearings indicate it's not a u-turn (which is correct). It then tries to reconcile the angles we have assigned to the turns. Rotating clockwise from the smallest angle, the angles should be increasing. However, the turn angles are 90°->0°->180°, so the middle angle is arbitrarily tweaked to 90.5° to make the angles consistent. Thus, we reach the state that triggers the assertion. |
The 7dp fix works by accident because it calculates the elevator path bearing accurately enough to not view it as a u-turn (angle is greater than epsilon), but in other intersection scenarios we would still encounter the same problem. In any case, I think the upgrading to 7dp coordinates is still a good idea. I see three possible ways to fix the assertion issue:
|
With the Washington State OSM extract.
Applying the fix #6215 to master.
osrm-extract
with the default foot profile triggers an angle assertion when processing intersection guidance.osrm-backend/src/guidance/turn_handler.cpp
Lines 239 to 243 in 79d4363
The offending intersection is in a bus station: https://www.openstreetmap.org/node/3750788725
The fact that the assertion is triggered within
handleThreeWayTurn
on a four-way intersection hints at the problem here.When processing the turns from one of the incoming edges to the intersection, it incorrectly identifies the straight-ahead turn as a u-turn, and discards the actual u-turn.
osrm-backend/src/extractor/intersection/intersection_analysis.cpp
Line 654 in 79d4363
Later in the processing it tries to fix the inconsistency in the angles as it rotates around the turns, effectively removing the u-turn from the list and making two 90 degree turns. This is what triggers the assertion.
osrm-backend/src/extractor/intersection/intersection_analysis.cpp
Lines 697 to 705 in 79d4363
Potential Fix
I'm not familiar with the guidance code, but increasing the coordinate precision to 7 decimal places is sufficient to fix the problem. Which probably means the nodes involved in the angle calculations are too close together to be calculated accurately at the current level of coordinate precision.
osrm-backend/include/util/coordinate.hpp
Line 44 in 79d4363
It's been noted previously (e.g. #3368) that coordinate precision needs increasing to improve consistency, but now we have a case where it's breaking logical assumptions.
The text was updated successfully, but these errors were encountered: