From 411313f666614159d06e8fdd2b009cf49cb6c905 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Wed, 11 Jan 2017 16:44:25 -0800 Subject: [PATCH] Backport NumLanesToTheRight/NumLanesToTheLeft to support 6ea9f9fdf1956444790d6992aeaa3170768f1297 --- src/engine/guidance/lane_processing.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/guidance/lane_processing.cpp b/src/engine/guidance/lane_processing.cpp index 3c2227ff2..fe60f2593 100644 --- a/src/engine/guidance/lane_processing.cpp +++ b/src/engine/guidance/lane_processing.cpp @@ -42,7 +42,19 @@ std::vector anticipateLaneChange(std::vector steps, // since at the moment we first group-by and only then do Lane Anticipation selectively. // // We do not have a source-target lane mapping, assume worst case for lanes to cross. - const auto to_cross = std::max(step.NumLanesToTheRight(), step.NumLanesToTheLeft()); + + // The following two lambda functions are backported from + // https://github.com/Project-OSRM/osrm-backend/pull/3474 + const auto NumLanesToTheRight = [](const RouteStep &step) -> LaneID { + return step.intersections.front().lanes.first_lane_from_the_right; + }; + const auto NumLanesToTheLeft = [](const RouteStep &step) -> LaneID { + LaneID const total = step.intersections.front().lane_description.size(); + return total - (step.intersections.front().lanes.lanes_in_turn + + step.intersections.front().lanes.first_lane_from_the_right); + }; + + const auto to_cross = std::max(NumLanesToTheRight(step), NumLanesToTheLeft(step)); const auto scale = 1 + to_cross; const auto threshold = scale * min_duration_needed_for_lane_change;