From 76457a423f879dec783198e4b83b2f0f8c08cf1d Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Thu, 22 Jun 2017 16:58:22 +0200 Subject: [PATCH] Propagate lane data across traffic lights --- features/guidance/turn-lanes.feature | 4 +- src/extractor/graph_compressor.cpp | 88 ++++++++++++++-------------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/features/guidance/turn-lanes.feature b/features/guidance/turn-lanes.feature index a42508729..627c806b4 100644 --- a/features/guidance/turn-lanes.feature +++ b/features/guidance/turn-lanes.feature @@ -1242,5 +1242,5 @@ Feature: Turn Lane Guidance | mdhk | road2 | 2 | | yes | When I route I should get - | waypoints | route | turns | lanes | locations | - | a,f | road1,road1,road1 | depart,continue uturn,arrive | ,, | a,d,f | + | waypoints | route | turns | lanes | locations | + | a,f | road1,road1,road1 | depart,continue uturn,arrive | ,left:true straight:false straight;right:false, | a,d,f | diff --git a/src/extractor/graph_compressor.cpp b/src/extractor/graph_compressor.cpp index 4e0bda103..56c76bf84 100644 --- a/src/extractor/graph_compressor.cpp +++ b/src/extractor/graph_compressor.cpp @@ -111,43 +111,6 @@ void GraphCompressor::Compress(const std::unordered_set &barrier_nodes, BOOST_ASSERT(graph.GetEdgeData(forward_e2).name_id == graph.GetEdgeData(reverse_e2).name_id); - // Do not compress edge if it crosses a traffic signal. - // This can't be done in CanCombineWith, becase we only store the - // traffic signals in the `traffic_lights` list, which EdgeData - // doesn't have access to. - const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end(); - if (has_node_penalty) - continue; - - // Get weights before graph is modified - const auto forward_weight1 = fwd_edge_data1.weight; - const auto forward_weight2 = fwd_edge_data2.weight; - const auto forward_duration1 = fwd_edge_data1.duration; - const auto forward_duration2 = fwd_edge_data2.duration; - - BOOST_ASSERT(0 != forward_weight1); - BOOST_ASSERT(0 != forward_weight2); - - const auto reverse_weight1 = rev_edge_data1.weight; - const auto reverse_weight2 = rev_edge_data2.weight; - const auto reverse_duration1 = rev_edge_data1.duration; - const auto reverse_duration2 = rev_edge_data2.duration; - - BOOST_ASSERT(0 != reverse_weight1); - BOOST_ASSERT(0 != reverse_weight2); - - // add weight of e2's to e1 - graph.GetEdgeData(forward_e1).weight += forward_weight2; - graph.GetEdgeData(reverse_e1).weight += reverse_weight2; - - // add duration of e2's to e1 - graph.GetEdgeData(forward_e1).duration += forward_duration2; - graph.GetEdgeData(reverse_e1).duration += reverse_duration2; - - // extend e1's to targets of e2's - graph.SetTarget(forward_e1, node_w); - graph.SetTarget(reverse_e1, node_u); - /* * Remember Lane Data for compressed parts. This handles scenarios where lane-data * is @@ -185,12 +148,51 @@ void GraphCompressor::Compress(const std::unordered_set &barrier_nodes, return front; return back; }; - graph.GetEdgeData(forward_e1).lane_description_id = - selectLaneID(graph.GetEdgeData(forward_e1).lane_description_id, - fwd_edge_data2.lane_description_id); - graph.GetEdgeData(reverse_e1).lane_description_id = - selectLaneID(graph.GetEdgeData(reverse_e1).lane_description_id, - rev_edge_data2.lane_description_id); + graph.GetEdgeData(forward_e1).lane_description_id = selectLaneID( + fwd_edge_data1.lane_description_id, fwd_edge_data2.lane_description_id); + graph.GetEdgeData(reverse_e1).lane_description_id = selectLaneID( + rev_edge_data1.lane_description_id, rev_edge_data2.lane_description_id); + graph.GetEdgeData(forward_e2).lane_description_id = selectLaneID( + fwd_edge_data2.lane_description_id, fwd_edge_data1.lane_description_id); + graph.GetEdgeData(reverse_e2).lane_description_id = selectLaneID( + rev_edge_data2.lane_description_id, rev_edge_data1.lane_description_id); + + // Do not compress edge if it crosses a traffic signal. + // This can't be done in CanCombineWith, becase we only store the + // traffic signals in the `traffic_lights` list, which EdgeData + // doesn't have access to. + const bool has_node_penalty = traffic_lights.find(node_v) != traffic_lights.end(); + if (has_node_penalty) + continue; + + // Get weights before graph is modified + const auto forward_weight1 = fwd_edge_data1.weight; + const auto forward_weight2 = fwd_edge_data2.weight; + const auto forward_duration1 = fwd_edge_data1.duration; + const auto forward_duration2 = fwd_edge_data2.duration; + + BOOST_ASSERT(0 != forward_weight1); + BOOST_ASSERT(0 != forward_weight2); + + const auto reverse_weight1 = rev_edge_data1.weight; + const auto reverse_weight2 = rev_edge_data2.weight; + const auto reverse_duration1 = rev_edge_data1.duration; + const auto reverse_duration2 = rev_edge_data2.duration; + + BOOST_ASSERT(0 != reverse_weight1); + BOOST_ASSERT(0 != reverse_weight2); + + // add weight of e2's to e1 + graph.GetEdgeData(forward_e1).weight += forward_weight2; + graph.GetEdgeData(reverse_e1).weight += reverse_weight2; + + // add duration of e2's to e1 + graph.GetEdgeData(forward_e1).duration += forward_duration2; + graph.GetEdgeData(reverse_e1).duration += reverse_duration2; + + // extend e1's to targets of e2's + graph.SetTarget(forward_e1, node_w); + graph.SetTarget(reverse_e1, node_u); // remove e2's (if bidir, otherwise only one) graph.DeleteEdge(node_v, forward_e2);