From 3680fc9d9033eb9c4a4cb9f15217a200e1b74d1f Mon Sep 17 00:00:00 2001 From: karenzshea Date: Wed, 16 Nov 2016 08:43:13 -0500 Subject: [PATCH] add check/test for intermediary intersections --- features/guidance/staggered-intersections.feature | 14 +++++++------- src/engine/guidance/post_processing.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/features/guidance/staggered-intersections.feature b/features/guidance/staggered-intersections.feature index 039f0f806..44dc13b73 100644 --- a/features/guidance/staggered-intersections.feature +++ b/features/guidance/staggered-intersections.feature @@ -121,25 +121,25 @@ Feature: Staggered Intersections | a,g | to_sea,road,to_sea,road,road | depart,turn right,turn left,notification straight,arrive | driving,driving,ferry,driving,driving | | g,a | road,to_sea,road,to_sea,to_sea | depart,notification straight,turn right,turn left,arrive | driving,ferry,driving,driving,driving | - Scenario: Staggered Intersection: do not collapse if a road class change is involved + Scenario: Staggered Intersection: do not collapse intermediary intersections Given the node map """ j a b c - d e f g - h + k l m i """ And the ways | nodes | highway | name | | abc | primary | Oak St | - | efg | residential | Oak St | - | jcdehi | residential | Cedar Dr | + | efg | residential | Elm St | + | klm | residential | Oak St | + | jceki | residential | Cedar Dr | When I route I should get | waypoints | route | turns | - | a,g | Oak St,Cedar Dr,Oak St,Oak St | depart,turn right,turn left,arrive | - | g,a | Oak St,Cedar Dr,Oak St,Oak St | depart,turn right,turn left,arrive | + | a,m | Oak St,Cedar Dr,Oak St,Oak St | depart,turn right,turn left,arrive | + | m,a | Oak St,Cedar Dr,Oak St,Oak St | depart,turn right,turn left,arrive | diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 5ba8bcbdc..315181b8d 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -855,7 +855,11 @@ bool isStaggeredIntersection(const RouteStep &previous, const RouteStep ¤t const auto no_mode_change = previous.mode == current.mode; - return is_short && (left_right || right_left) && no_mode_change; + // previous step maneuver intersections should be length 1 to indicate that + // there are no intersections between the two potentially collapsible turns + const auto no_intermediary_intersections = previous.intersections.size() == 1; + + return is_short && (left_right || right_left) && no_mode_change && no_intermediary_intersections; } } // namespace @@ -1164,8 +1168,8 @@ std::vector collapseTurns(std::vector steps) invalidateStep(steps[index]); } } - // If we look at two consecutive name changes, we can check for a name oszillation. - // A name oszillation changes from name A shortly to name B and back to A. + // If we look at two consecutive name changes, we can check for a name oscillation. + // A name oscillation changes from name A shortly to name B and back to A. // In these cases, the name change will be suppressed. else if (one_back_index > 0 && compatible(current_step, one_back_step) && ((isCollapsableInstruction(current_step.maneuver.instruction) &&