From 3ac061c546d5c65eec77f8ad4ed747061e3aedd3 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Thu, 21 Apr 2016 22:51:38 +0200 Subject: [PATCH] fix guidance issues / improve tests --- features/guidance/fork.feature | 1 - features/guidance/turn.feature | 2 -- include/extractor/guidance/constants.hpp | 4 +-- src/extractor/guidance/turn_handler.cpp | 33 ++++++------------------ 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/features/guidance/fork.feature b/features/guidance/fork.feature index 916799e74..f5c808795 100644 --- a/features/guidance/fork.feature +++ b/features/guidance/fork.feature @@ -245,7 +245,6 @@ Feature: Fork Instructions | a,c | abd,bc,bc | depart,turn slight left,arrive | | a,d | abd,abd | depart,arrive | - @pr2275 @bug Scenario: Tripple fork Given the node map | | | | | | | | | c | diff --git a/features/guidance/turn.feature b/features/guidance/turn.feature index 295a2a65b..47cd63356 100644 --- a/features/guidance/turn.feature +++ b/features/guidance/turn.feature @@ -726,7 +726,6 @@ Feature: Simple Turns | a,e | abc,eb,eb | depart,turn right,arrive | | a,f | abc,fb,fb | depart,turn slight right,arrive | - @bug @pr2275 Scenario: Right Turn Assignment Three Conflicting Turns with invalid - 2 Given the node map | | | g | | | @@ -787,7 +786,6 @@ Feature: Simple Turns | a,e | abc,be,be | depart,turn right,arrive | | a,f | abc,bf,bf | depart,turn sharp right,arrive | - @bug @pr2275 Scenario: Conflicting Turns with well distinguished turn (back) Given the node map | a | | | b | | | c | diff --git a/include/extractor/guidance/constants.hpp b/include/extractor/guidance/constants.hpp index 041868221..e27b96008 100644 --- a/include/extractor/guidance/constants.hpp +++ b/include/extractor/guidance/constants.hpp @@ -16,9 +16,9 @@ const double constexpr STRAIGHT_ANGLE = 180.; const double constexpr MAXIMAL_ALLOWED_NO_TURN_DEVIATION = 3.; // angle that lies between two nearly indistinguishable roads const double constexpr NARROW_TURN_ANGLE = 40.; -const double constexpr GROUP_ANGLE = 90; +const double constexpr GROUP_ANGLE = 60; // angle difference that can be classified as straight, if its the only narrow turn -const double constexpr FUZZY_ANGLE_DIFFERENCE = 15.; +const double constexpr FUZZY_ANGLE_DIFFERENCE = 20.; const double constexpr DISTINCTION_RATIO = 2; const unsigned constexpr INVALID_NAME_ID = 0; diff --git a/src/extractor/guidance/turn_handler.cpp b/src/extractor/guidance/turn_handler.cpp index ac3d0cdca..1aafc473f 100644 --- a/src/extractor/guidance/turn_handler.cpp +++ b/src/extractor/guidance/turn_handler.cpp @@ -18,19 +18,6 @@ namespace extractor { namespace guidance { -namespace detail -{ -inline FunctionalRoadClass roadClass(const ConnectedRoad &road, - const util::NodeBasedDynamicGraph &graph) -{ - return graph.GetEdgeData(road.turn.eid).road_classification.road_class; -} - -inline bool isRampClass(EdgeID eid, const util::NodeBasedDynamicGraph &node_based_graph) -{ - return isRampClass(node_based_graph.GetEdgeData(eid).road_classification.road_class); -} -} TurnHandler::TurnHandler(const util::NodeBasedDynamicGraph &node_based_graph, const std::vector &node_info_list, @@ -282,7 +269,7 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection DirectionModifier::SlightRight}; } } - else if (fork_range.second - fork_range.second == 2) + else if (fork_range.second - fork_range.first == 2) { assignFork(via_edge, intersection[fork_range.second], intersection[fork_range.first + 1], intersection[fork_range.first]); @@ -373,12 +360,6 @@ std::size_t TurnHandler::findObviousTurn(const EdgeID via_edge, if (best_deviation >= 2 * NARROW_TURN_ANGLE) return 0; - // TODO incorporate road class in decision - if (best != 0 && best_deviation < MAXIMAL_ALLOWED_NO_TURN_DEVIATION) - { - return best; - } - // has no obvious continued road if (best_continue == 0 || true) { @@ -534,7 +515,6 @@ Intersection TurnHandler::assignRightTurns(const EdgeID via_edge, angularDeviation(intersection[1].turn.angle, intersection[2].turn.angle) < GROUP_ANGLE))) { - BOOST_ASSERT(intersection[1].entry_allowed && intersection[2].entry_allowed && intersection[3].entry_allowed); // count backwards from the slightest turn @@ -624,19 +604,22 @@ std::pair TurnHandler::findFork(const Intersection &in } while (left + 1 < intersection.size() && angularDeviation(intersection[left].turn.angle, intersection[left + 1].turn.angle) < - NARROW_TURN_ANGLE) + NARROW_TURN_ANGLE && + angularDeviation(intersection[left].turn.angle, STRAIGHT_ANGLE) <= GROUP_ANGLE) ++left; while (right > 1 && angularDeviation(intersection[right].turn.angle, - intersection[right - 1].turn.angle) < NARROW_TURN_ANGLE) + intersection[right - 1].turn.angle) < NARROW_TURN_ANGLE && + angularDeviation(intersection[right - 1].turn.angle, STRAIGHT_ANGLE) <= GROUP_ANGLE) --right; // TODO check whether 2*NARROW_TURN is too large if (0 < right && right < left && angularDeviation(intersection[left].turn.angle, - intersection[(left + 1) % intersection.size()].turn.angle) >= 60 && + intersection[(left + 1) % intersection.size()].turn.angle) >= + GROUP_ANGLE && angularDeviation(intersection[right].turn.angle, intersection[right - 1].turn.angle) >= - 60) + GROUP_ANGLE) return std::make_pair(right, left); } return std::make_pair(std::size_t{0}, std::size_t{0});