From f4db79fe9b644081d6b2478ba0f3e37b3e5cfcb9 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Mon, 4 Jul 2016 16:31:30 +0200 Subject: [PATCH] fix obvious turn collapsing for straight turns --- CHANGELOG.md | 5 +++++ features/guidance/collapse.feature | 12 ++++++------ features/guidance/turn.feature | 26 +++++++++++++++++++++++++ src/engine/guidance/post_processing.cpp | 7 ++++--- src/extractor/guidance/turn_handler.cpp | 19 +++++++++++------- 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf6c92fa0..088927aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 5.3.0 + Changes from 5.3.0-rc.2 + - Guidance + - Improved detection of obvious turns + # 5.3.0 RC2 Changes from 5.3.0-rc.1 - Bugfixes diff --git a/features/guidance/collapse.feature b/features/guidance/collapse.feature index 290575205..709cf7cc8 100644 --- a/features/guidance/collapse.feature +++ b/features/guidance/collapse.feature @@ -606,13 +606,13 @@ Feature: Collapse | restriction | bc | fdcg | c | no_right_turn | When I route I should get - | waypoints | route | turns | - | a,g | road,cross,cross | depart,turn left,arrive | - | a,e | road,road,road | depart,continue slight right,arrive | - # We should discuss whether the next item should be collapsed to depart,turn right,arrive. - | a,f | road,road,cross,cross | depart,continue slight right,turn right,arrive | + | waypoints | route | turns | + | a,g | road,cross,cross | depart,turn left,arrive | + | a,e | road,road,road | depart,continue slight right,arrive | + # We should discuss whether the next item should be collapsed to depart,turn right,arrive. + | a,f | road,road,cross,cross | depart,continue slight right,turn right,arrive | - Scenario: On-Off on Highway + Scenario: On-Off on Highway Given the node map | f | | | | | a | b | c | d | diff --git a/features/guidance/turn.feature b/features/guidance/turn.feature index 0585ee1f1..e61f8508c 100644 --- a/features/guidance/turn.feature +++ b/features/guidance/turn.feature @@ -853,3 +853,29 @@ Feature: Simple Turns | a,c | depart,arrive | road,road | | d,a | depart,turn left,arrive | in,road,road | | d,c | depart,new name straight,arrive | in,road,road | + + Scenario: Channing Street + Given the node map + | | | g | f | | + | | | | | | + | d | | c | b | a | + | | | | | | + | | | | | | + | | | h | e | | + + And the nodes + | node | highway | + | c | traffic_signals | + | b | traffic_signals | + + And the ways + | nodes | name | highway | oneway | + | ab | Channing Street Northeast | residential | no | + | bcd | Channing Street Northwest | residential | yes | + | ebf | North Capitol Street Northeast | primary | yes | + | gch | North Capitol Street Northeast | primary | yes | + + When I route I should get + | waypoints | turns | route | + | a,d | depart,arrive | Channing Street Northeast,Channing Street Northwest | + | a,h | depart,turn left,arrive | Channing Street Northeast,North Capitol Street Northeast,North Capitol Street Northeast | diff --git a/src/engine/guidance/post_processing.cpp b/src/engine/guidance/post_processing.cpp index 745443d94..55b66ac2c 100644 --- a/src/engine/guidance/post_processing.cpp +++ b/src/engine/guidance/post_processing.cpp @@ -385,7 +385,9 @@ void collapseTurnAt(std::vector &steps, { BOOST_ASSERT(!one_back_step.intersections.empty()); if (TurnType::Continue == current_step.maneuver.instruction.type || - TurnType::Suppressed == current_step.maneuver.instruction.type) + (TurnType::Suppressed == current_step.maneuver.instruction.type && + current_step.maneuver.instruction.direction_modifier != + DirectionModifier::Straight)) steps[step_index].maneuver.instruction.type = TurnType::Turn; else if (TurnType::Merge == current_step.maneuver.instruction.type) { @@ -399,6 +401,7 @@ void collapseTurnAt(std::vector &steps, DirectionModifier::Straight && one_back_step.intersections.front().bearings.size() > 2) steps[step_index].maneuver.instruction.type = TurnType::Turn; + steps[two_back_index] = elongate(std::move(steps[two_back_index]), one_back_step); // If the previous instruction asked to continue, the name change will have to // be changed into a turn @@ -416,9 +419,7 @@ void collapseTurnAt(std::vector &steps, if ((TurnType::Continue == one_back_step.maneuver.instruction.type || TurnType::Suppressed == one_back_step.maneuver.instruction.type) && current_step.name_id != steps[two_back_index].name_id) - { steps[one_back_index].maneuver.instruction.type = TurnType::Turn; - } else if (TurnType::Turn == one_back_step.maneuver.instruction.type && current_step.name_id == steps[two_back_index].name_id) { diff --git a/src/extractor/guidance/turn_handler.cpp b/src/extractor/guidance/turn_handler.cpp index dff2fa424..786412172 100644 --- a/src/extractor/guidance/turn_handler.cpp +++ b/src/extractor/guidance/turn_handler.cpp @@ -1,7 +1,7 @@ -#include "extractor/guidance/turn_handler.hpp" #include "extractor/guidance/constants.hpp" #include "extractor/guidance/intersection_scenario_three_way.hpp" #include "extractor/guidance/toolkit.hpp" +#include "extractor/guidance/turn_handler.hpp" #include "util/guidance/toolkit.hpp" @@ -88,18 +88,20 @@ Intersection TurnHandler::handleThreeWayTurn(const EdgeID via_edge, Intersection const bool is_ramp = isRampClass(first_class); const bool is_obvious_by_road_class = - (!is_ramp && (2 * getPriority(first_class) < getPriority(second_class))) || + (!is_ramp && (2 * getPriority(first_class) < getPriority(second_class)) && + in_data.road_classification.road_class == first_class) || (!isLowPriorityRoadClass(first_class) && isLowPriorityRoadClass(second_class)); if (is_obvious_by_road_class) return true; - const bool other_is_obvious_by_road_flass = + const bool other_is_obvious_by_road_class = (!isRampClass(second_class) && - (2 * getPriority(second_class) < getPriority(first_class))) || + (2 * getPriority(second_class) < getPriority(first_class)) && + in_data.road_classification.road_class == second_class) || (!isLowPriorityRoadClass(second_class) && isLowPriorityRoadClass(first_class)); - if (other_is_obvious_by_road_flass) + if (other_is_obvious_by_road_class) return false; const bool turn_is_perfectly_straight = angularDeviation(road.turn.angle, STRAIGHT_ANGLE) < @@ -375,6 +377,7 @@ std::size_t TurnHandler::findObviousTurn(const EdgeID via_edge, double best_continue_deviation = 180; const EdgeData &in_data = node_based_graph.GetEdgeData(via_edge); + const auto in_class = in_data.road_classification.road_class; for (std::size_t i = 1; i < intersection.size(); ++i) { const double deviation = angularDeviation(intersection[i].turn.angle, STRAIGHT_ANGLE); @@ -388,9 +391,11 @@ std::size_t TurnHandler::findObviousTurn(const EdgeID via_edge, auto continue_class = node_based_graph.GetEdgeData(intersection[best_continue].turn.eid) .road_classification.road_class; if (intersection[i].entry_allowed && out_data.name_id == in_data.name_id && - (best_continue == 0 || continue_class > out_data.road_classification.road_class || + (best_continue == 0 || (continue_class > out_data.road_classification.road_class && + in_class != continue_class) || (deviation < best_continue_deviation && - out_data.road_classification.road_class == continue_class))) + (out_data.road_classification.road_class == continue_class || + in_class == out_data.road_classification.road_class)))) { best_continue_deviation = deviation; best_continue = i;