don't collapse u-turns into combined turns
This commit is contained in:
parent
74bc8966a8
commit
d660c1609c
@ -26,6 +26,7 @@
|
||||
- Fixed a copy/paste issue assigning wrong directions in similar turns (left over right)
|
||||
- #4074: fixed a bug that would announce entering highway ramps as u-turns
|
||||
- #4122: osrm-routed/libosrm should throw exception when a dataset incompatible with the requested algorithm is loaded
|
||||
- Avoid collapsing u-turns into combined turn instructions
|
||||
|
||||
# 5.7.1
|
||||
- Bugfixes
|
||||
|
@ -1073,4 +1073,4 @@ Feature: Collapse
|
||||
|
||||
When I route I should get
|
||||
| waypoints | bearings | route | turns | locations |
|
||||
| 1,2 | 90 270 | ab,bd,ab,ab | depart,turn right,end of road right,arrive | _,b,b,_ |
|
||||
| 1,2 | 90 270 | ab,bd,bd,ab,ab | depart,turn left,continue uturn,turn right,arrive | _,b,d,b,_ |
|
||||
|
@ -61,6 +61,22 @@ bool isShortAndUndisturbed(const RouteStep &step)
|
||||
return is_short && noIntermediaryIntersections(step);
|
||||
}
|
||||
|
||||
// On dual carriageways, we might want to use u-turns in combination with new-name instructions.
|
||||
// Otherwise a u-turn should never be part of a collapsing instructions.
|
||||
bool noBadUTurnCombination(const RouteStepIterator first, const RouteStepIterator second)
|
||||
{
|
||||
auto has_uturn = hasModifier(*first, DirectionModifier::UTurn) ||
|
||||
hasModifier(*second, DirectionModifier::UTurn);
|
||||
|
||||
auto const from_name_change_into_uturn =
|
||||
hasTurnType(*first, TurnType::NewName) && hasModifier(*second, DirectionModifier::UTurn);
|
||||
|
||||
auto const uturn_into_name_change =
|
||||
hasTurnType(*second, TurnType::NewName) && hasModifier(*first, DirectionModifier::UTurn);
|
||||
|
||||
return !has_uturn || from_name_change_into_uturn || uturn_into_name_change;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool basicCollapsePreconditions(const RouteStepIterator first, const RouteStepIterator second)
|
||||
@ -70,7 +86,10 @@ bool basicCollapsePreconditions(const RouteStepIterator first, const RouteStepIt
|
||||
|
||||
const auto waypoint_type = hasWaypointType(*first) || hasWaypointType(*second);
|
||||
|
||||
return !has_roundabout_type && !waypoint_type && haveSameMode(*first, *second);
|
||||
const auto contains_bad_uturn = !noBadUTurnCombination(first, second);
|
||||
|
||||
return !has_roundabout_type && !waypoint_type && haveSameMode(*first, *second) &&
|
||||
!contains_bad_uturn;
|
||||
}
|
||||
|
||||
bool basicCollapsePreconditions(const RouteStepIterator first,
|
||||
@ -81,8 +100,11 @@ bool basicCollapsePreconditions(const RouteStepIterator first,
|
||||
hasRoundaboutType(second->maneuver.instruction) ||
|
||||
hasRoundaboutType(third->maneuver.instruction);
|
||||
|
||||
const auto contains_bad_uturn =
|
||||
!noBadUTurnCombination(first, second) && !noBadUTurnCombination(second, third);
|
||||
|
||||
// require modes to match up
|
||||
return !has_roundabout_type && haveSameMode(*first, *second, *third);
|
||||
return !has_roundabout_type && haveSameMode(*first, *second, *third) && !contains_bad_uturn;
|
||||
}
|
||||
|
||||
bool isStaggeredIntersection(const RouteStepIterator step_prior_to_intersection,
|
||||
|
Loading…
Reference in New Issue
Block a user