From f8002480c26bee47b35d3cfe80170fadd679ed08 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Fri, 5 May 2017 12:59:54 +0200 Subject: [PATCH] fix continue_straight interaction with bearing specification --- features/testbot/via.feature | 61 +++++++++++++++++++++++++++++++++ src/engine/plugins/viaroute.cpp | 21 ++---------- 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/features/testbot/via.feature b/features/testbot/via.feature index b06d1ecfe..2523dac6e 100644 --- a/features/testbot/via.feature +++ b/features/testbot/via.feature @@ -352,3 +352,64 @@ Feature: Via points | waypoints | bearings | route | turns | | 1,a | 90,2 270,2 | ab,ab,ab | depart,turn uturn,arrive | | 1,b | 270,2 90,2 | ab,ab,ab | depart,turn uturn,arrive | + + Scenario: Continue Straight in presence of Bearings + Given the node map + """ + h - a 1 b -- g + | | + | |- 2 c - f + | 3 + e ------ d - i + | + j + """ + + And the query options + | continue_straight | false | + + And the ways + | nodes | oneway | + | ab | no | + | bc | no | + | cdea | no | + | ah | yes | + | bg | yes | + | cf | yes | + | di | yes | + | dj | yes | + + When I route I should get + | waypoints | bearings | route | + | 1,2,3 | 270,90 180,180 180,180 | ab,cdea,cdea,bc,bc,bc,cdea,cdea | + + Scenario: Continue Straight in presence of Bearings + Given the node map + """ + h - a 1 b -- g + | | + | |- 2 c - f + | 3 + e ------ d - i + | + j + """ + + And the query options + | continue_straight | true | + + And the ways + | nodes | oneway | + | ab | no | + | bc | no | + | cdea | no | + | ah | yes | + | bg | yes | + | cf | yes | + | di | yes | + | dj | yes | + + When I route I should get + | waypoints | bearings | route | + | 1,2,3 | 270,90 180,180 180,180 | ab,cdea,cdea,bc,bc,bc,ab,cdea,cdea,cdea | + diff --git a/src/engine/plugins/viaroute.cpp b/src/engine/plugins/viaroute.cpp index b588ac9f6..2be8756eb 100644 --- a/src/engine/plugins/viaroute.cpp +++ b/src/engine/plugins/viaroute.cpp @@ -77,27 +77,10 @@ ViaRoutePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFaca auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs); - const bool continue_straight_at_waypoint = route_parameters.continue_straight - ? *route_parameters.continue_straight - : facade.GetContinueStraightDefault(); - std::vector start_end_nodes; - auto build_phantom_pairs = [&start_end_nodes, continue_straight_at_waypoint]( - const PhantomNode &first_node, const PhantomNode &second_node) { + auto build_phantom_pairs = [&start_end_nodes](const PhantomNode &first_node, + const PhantomNode &second_node) { start_end_nodes.push_back(PhantomNodes{first_node, second_node}); - auto &last_inserted = start_end_nodes.back(); - // enable forward direction if possible - if (last_inserted.source_phantom.forward_segment_id.id != SPECIAL_SEGMENTID) - { - last_inserted.source_phantom.forward_segment_id.enabled |= - !continue_straight_at_waypoint; - } - // enable reverse direction if possible - if (last_inserted.source_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID) - { - last_inserted.source_phantom.reverse_segment_id.enabled |= - !continue_straight_at_waypoint; - } }; util::for_each_pair(snapped_phantoms, build_phantom_pairs);