From 1a96483f7bc777a69bf28062082c5f9eb60ad739 Mon Sep 17 00:00:00 2001 From: karenzshea Date: Thu, 15 Sep 2016 10:37:28 -0400 Subject: [PATCH] prefer notification over new-name/suppressed types --- features/guidance/notification.feature | 57 +++++++++++++++++++ .../guidance/intersection_handler.cpp | 15 ++--- 2 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 features/guidance/notification.feature diff --git a/features/guidance/notification.feature b/features/guidance/notification.feature new file mode 100644 index 000000000..f6f17ae2b --- /dev/null +++ b/features/guidance/notification.feature @@ -0,0 +1,57 @@ +@routing @guidance @mode-change +Feature: Notification on turn onto mode change + + Background: + Given the profile "car" + Given a grid size of 400 meters + + Scenario: Turn onto a Ferry + Given the node map + | f | | | | | + | b | | | d | | + | a | | | | e | + + And the ways + | nodes | highway | route | name | + | abf | primary | | | + | bd | | ferry | ferry | + | de | primary | | | + + When I route I should get + | waypoints | route | turns | modes | + | a,e | ,ferry,, | depart,turn right,notification right,arrive | driving,ferry,driving,driving | + + Scenario: Turn onto a Ferry + Given the node map + | h | | | g | + | a | c | | e | + | b | | | f | + + And the ways + | nodes | highway | route | name | + | ac | primary | | | + | bah | primary | | | + | ec | | ferry | ferry | + | gef | primary | | | + + When I route I should get + | waypoints | route | turns | modes | + | g,h | ,ferry,,, | depart,turn right,notification straight,turn right,arrive | driving,ferry,driving,driving,driving | + | b,g | ,,ferry,, | depart,turn right,notification straight,turn left,arrive | driving,driving,ferry,driving,driving | + + Scenario: Straight onto a Ferry + Given the node map + | | | | | | + | | c | d | | i | + | a | | | | | + | | | | f | | + + And the ways + | nodes | highway | route | name | + | ac | primary | | | + | dc | | ferry | ferry | + | df | primary | | | + + When I route I should get + | waypoints | route | turns | modes | + | a,f | ,ferry,, | depart,notification right,notification right,arrive | driving,ferry,driving,driving | diff --git a/src/extractor/guidance/intersection_handler.cpp b/src/extractor/guidance/intersection_handler.cpp index 8d80138d2..4e9c0b63e 100644 --- a/src/extractor/guidance/intersection_handler.cpp +++ b/src/extractor/guidance/intersection_handler.cpp @@ -1,5 +1,5 @@ -#include "extractor/guidance/intersection_handler.hpp" #include "extractor/guidance/constants.hpp" +#include "extractor/guidance/intersection_handler.hpp" #include "extractor/guidance/toolkit.hpp" #include "util/coordinate_calculation.hpp" @@ -110,10 +110,7 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t else if (in_data.road_classification.IsRampClass() && out_data.road_classification.IsRampClass()) { - if (in_mode == out_mode) - return {TurnType::Suppressed, getTurnDirection(road.turn.angle)}; - else - return {TurnType::Notification, getTurnDirection(road.turn.angle)}; + return {in_mode == out_mode ? TurnType::Suppressed : TurnType::Notification, getTurnDirection(road.turn.angle)}; } else { @@ -140,15 +137,13 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t } else { - return {TurnType::NewName, getTurnDirection(road.turn.angle)}; + return {in_mode == out_mode ? TurnType::NewName : TurnType::Notification, getTurnDirection(road.turn.angle)}; } } + // name has not changed, suppress a turn here or indicate mode change else { - if (in_mode == out_mode) - return {TurnType::Suppressed, getTurnDirection(road.turn.angle)}; - else - return {TurnType::Notification, getTurnDirection(road.turn.angle)}; + return {in_mode == out_mode ? TurnType::Suppressed : TurnType::Notification, getTurnDirection(road.turn.angle)}; } } BOOST_ASSERT(type == TurnType::Continue);