- Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
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
| Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection intersection) const | |
| { | |
| BOOST_ASSERT(intersection.size() == 3); | |
| const auto obvious_index = findObviousTurn(via_edge, intersection); | |
| BOOST_ASSERT(intersection[0].angle < 0.001); |
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.
| const auto is_uturn_angle = is_uturn(turn_angle); |
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
| // Check that the perceived angles order is the same as the initial OSM one | |
| if (next->first.angle < curr->first.angle) | |
| { // If the true bearing is out of the initial order (next before current) then | |
| // adjust the next road angle to keep the order. The adjustment angle is at most | |
| // 0.5° or a half-angle between the current angle and 360° to prevent overlapping | |
| const auto angle_adjustment = | |
| std::min(.5, util::restrictAngleToValidRange(360. - curr->first.angle) / 2.); | |
| next->first.angle = | |
| util::restrictAngleToValidRange(curr->first.angle + angle_adjustment); |
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
| constexpr const double COORDINATE_PRECISION = 1e6; |
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.
