From 388d84a89ed2eff812e8f68bc4444f76e01abb20 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Wed, 2 Nov 2016 23:59:35 +0100 Subject: [PATCH] check for compatibility in post-processing (#3227) --- CHANGELOG.md | 1 + features/guidance/ramp.feature | 21 +++++++++++++++++++++ src/engine/guidance/post_processing.cpp | 8 +++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c8db863a..6db567b35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - fixed a bug where polyline decoding on a defective polyline could end up in out-of-bound access on a vector - fixed compile errors in tile unit-test framework - fixed a bug that could result in inconsistent behaviour when collapsing instructions + - fixed a bug that could result in crashes when leaving a ferry directly onto a motorway ramp - Debug Tiles - Added support for turn penalties diff --git a/features/guidance/ramp.feature b/features/guidance/ramp.feature index 1b3280c70..f23213061 100644 --- a/features/guidance/ramp.feature +++ b/features/guidance/ramp.feature @@ -255,3 +255,24 @@ Feature: Ramp Guidance | waypoints | route | turns | | a,d | , | depart,arrive | | b,d | , | depart,arrive | + + Scenario: Ferry Onto A Ramp + Given the node map + """ + d - e - g + | + a - b ~ ~ ~ ~ ~ ~ ~ c + ` f + """ + + And the ways + | nodes | highway | route | name | ref | + | ab | primary | | boarding | | + | bc | | ferry | boaty mc boatface | m2 | + | cf | | ferry | boaty mc boatface | | + | cd | | ferry | boaty mc boatface's cousin | | + | de | motorway_link | | | | + + When I route I should get + | waypoints | route | + | a,e | boarding,boaty mc boatface,boaty mc boatface's cousin,, | diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 3951bcb0c..23be6f354 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -462,7 +462,7 @@ void collapseUTurn(std::vector &steps, // additionall collapse a name-change as welll const auto next_step_index = step_index + 1; const bool continues_with_name_change = - (next_step_index < steps.size()) && + (next_step_index < steps.size()) && compatible(steps[step_index], steps[next_step_index]) && ((steps[next_step_index].maneuver.instruction.type == TurnType::UseLane && steps[next_step_index].maneuver.instruction.direction_modifier == DirectionModifier::Straight) || @@ -777,7 +777,8 @@ void collapseTurnAt(std::vector &steps, invalidateStep(steps[step_index]); } else if (TurnType::Suppressed == current_step.maneuver.instruction.type && - !isNoticeableNameChange(one_back_step, current_step)) + !isNoticeableNameChange(one_back_step, current_step) && + compatible(one_back_step, current_step)) { steps[one_back_index] = elongate(std::move(steps[one_back_index]), current_step); const auto angle = findTotalTurnAngle(one_back_step, current_step); @@ -787,7 +788,8 @@ void collapseTurnAt(std::vector &steps, invalidateStep(steps[step_index]); } else if (TurnType::Turn == one_back_step.maneuver.instruction.type && - TurnType::OnRamp == current_step.maneuver.instruction.type) + TurnType::OnRamp == current_step.maneuver.instruction.type && + compatible(one_back_step, current_step)) { // turning onto a ramp makes the first turn into a ramp steps[one_back_index] = elongate(std::move(steps[one_back_index]), current_step);