From 311b348d093120bf772dfc019e8a2f5b901fdcf8 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Mon, 27 Jun 2016 17:05:13 +0200 Subject: [PATCH] handle sliproads at traffic lights --- .../guidance/dedicated-turn-roads.feature | 64 ++++++++++++++++--- src/extractor/guidance/turn_analysis.cpp | 33 ++++++++-- 2 files changed, 81 insertions(+), 16 deletions(-) diff --git a/features/guidance/dedicated-turn-roads.feature b/features/guidance/dedicated-turn-roads.feature index 3513ad392..30cb87e8f 100644 --- a/features/guidance/dedicated-turn-roads.feature +++ b/features/guidance/dedicated-turn-roads.feature @@ -57,20 +57,21 @@ Feature: Slipways and Dedicated Turn Lanes Scenario: Inner city expressway with on road Given the node map - | a | b | | | | c | - | | | | | f | | - | | | | | | | - | | | | | | | - | | | | | | | - | | | | | | d | - | | | | | | | - | | | | | | | - | | | | | | | - | | | | | | e | + | a | b | | | | c | g | + | | | | | f | | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | | d | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | | e | | And the ways | nodes | highway | name | | abc | primary | road | + | cg | primary | road | | bfd | trunk_link | | | cde | trunk | trunk | @@ -123,3 +124,46 @@ Feature: Slipways and Dedicated Turn Lanes When I route I should get | waypoints | route | turns | | a,f | road,road,road | depart,continue uturn,arrive | + + Scenario: Schwarzwaldstrasse Autobahn + Given the node map + | | | | | i | | | | | | h | | | | | g | + | | | j | | | | | | | | | | | | | | + | a | | | | | | | k | | | | | | | | | + | | | | b | | r | c | | d | | e | | | | | f | + | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | + | | | | | | l | | | | | | | | | | | + | | | | | | m | | | | | | | | | | | + | | | | | | | n | | q | | | | | | | | + | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | + | | | | | | | | | | | | | | | | | + | | | | | | | o | | p | | | | | | | | + + And the nodes + # the traffic light at `l` is not actually in the data, but necessary for the test to check everything + # http://www.openstreetmap.org/#map=19/48.99211/8.40336 + | node | highway | + | r | traffic_signals | + | l | traffic_signals | + + And the ways + | nodes | highway | name | ref | oneway | + | abrcd | secondary | Schwarzwaldstrasse | L561 | yes | + | hija | secondary | Schwarzwaldstrasse | L561 | yes | + | def | secondary | Ettlinger Strasse | | yes | + | gh | secondary | Ettlinger Strasse | | yes | + | blmn | secondary_link | | L561 | yes | + | hkc | secondary_link | Ettlinger Strasse | | yes | + | qdki | secondary_link | Ettlinger Allee | | yes | + | cn | secondary_link | Ettlinger Allee | | yes | + | no | primary | Ettlinger Allee | | yes | + | pq | primary | Ettlinger Allee | | yes | + | qe | secondary_link | Ettlinger Allee | | yes | + + When I route I should get + | waypoints | route | turns | + | a,o | Schwarzwaldstrasse (L561),Ettlinger Allee,Ettlinger Allee | depart,turn right,arrive | diff --git a/src/extractor/guidance/turn_analysis.cpp b/src/extractor/guidance/turn_analysis.cpp index 07024c501..a95ff907e 100644 --- a/src/extractor/guidance/turn_analysis.cpp +++ b/src/extractor/guidance/turn_analysis.cpp @@ -1,6 +1,6 @@ -#include "extractor/guidance/turn_analysis.hpp" #include "extractor/guidance/classification_data.hpp" #include "extractor/guidance/constants.hpp" +#include "extractor/guidance/turn_analysis.hpp" #include "util/coordinate.hpp" #include "util/coordinate_calculation.hpp" @@ -164,7 +164,6 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id, }); const bool hasNext = next_road != intersection.end(); - if (!hasNext) { return intersection; @@ -177,10 +176,21 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id, return intersection; } - const auto next_road_next_intersection = - intersection_generator(intersection_node_id, next_road->turn.eid); + auto next_intersection_node = node_based_graph.GetTarget(next_road->turn.eid); - const auto next_intersection_node = node_based_graph.GetTarget(next_road->turn.eid); + const auto next_road_next_intersection = [&]() { + auto intersection = intersection_generator(intersection_node_id, next_road->turn.eid); + auto in_edge = next_road->turn.eid; + //skip over traffic lights + if(intersection.size() == 2) + { + const auto node = node_based_graph.GetTarget(in_edge); + in_edge = intersection[1].turn.eid; + next_intersection_node = node_based_graph.GetTarget(in_edge); + intersection = intersection_generator(node, in_edge); + } + return intersection; + }(); std::unordered_set target_road_names; @@ -194,7 +204,18 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id, { if (linkTest(road)) { - auto target_intersection = intersection_generator(intersection_node_id, road.turn.eid); + const auto target_intersection = [&](NodeID node, EdgeID eid) { + auto intersection = intersection_generator(node, eid); + //skip over traffic lights + if(intersection.size() == 2) + { + node = node_based_graph.GetTarget(eid); + eid = intersection[1].turn.eid; + intersection = intersection_generator(node, eid); + } + return intersection; + }(intersection_node_id, road.turn.eid); + for (const auto &candidate_road : target_intersection) { const auto &candidate_data = node_based_graph.GetEdgeData(candidate_road.turn.eid);