From b503e96a98cd44099ccfc7ab999b3f3987959739 Mon Sep 17 00:00:00 2001 From: Michael Bell Date: Sun, 5 May 2024 21:56:01 +0100 Subject: [PATCH] Remove force-loop checks for routes with u-turns (#6858) Each leg of a via-route supporting u-turns does not need to consider force-loops. Negative weight checks are sufficient to prevent incorrect results when waypoints are on the same edge. --- CHANGELOG.md | 1 + .../routing_algorithms/shortest_path_impl.hpp | 22 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd5967c8c0d..ec582b7b3ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ - FIXED: Fix adding traffic signal penalties during compression [#6419](https://github.com/Project-OSRM/osrm-backend/pull/6419) - FIXED: Correctly handle compressed traffic signals. [#6724](https://github.com/Project-OSRM/osrm-backend/pull/6724) - FIXED: Fix bug when searching for maneuver overrides [#6739](https://github.com/Project-OSRM/osrm-backend/pull/6739) + - FIXED: Remove force-loop checks for routes with u-turns [#6858](https://github.com/Project-OSRM/osrm-backend/pull/6858) - Debug tiles: - FIXED: Ensure speed layer features have unique ids. [#6726](https://github.com/Project-OSRM/osrm-backend/pull/6726) diff --git a/include/engine/routing_algorithms/shortest_path_impl.hpp b/include/engine/routing_algorithms/shortest_path_impl.hpp index f23ae76542e..5c38e6baeaa 100644 --- a/include/engine/routing_algorithms/shortest_path_impl.hpp +++ b/include/engine/routing_algorithms/shortest_path_impl.hpp @@ -19,8 +19,7 @@ void searchWithUTurn(SearchEngineData &engine_working_data, typename SearchEngineData::QueryHeap &forward_heap, typename SearchEngineData::QueryHeap &reverse_heap, const PhantomEndpointCandidates &candidates, - const EdgeWeight &total_weight, - EdgeWeight &new_total_weight, + EdgeWeight &leg_weight, std::vector &leg_packed_path) { forward_heap.Clear(); @@ -31,14 +30,14 @@ void searchWithUTurn(SearchEngineData &engine_working_data, if (source.IsValidForwardSource()) { forward_heap.Insert(source.forward_segment_id.id, - total_weight - source.GetForwardWeightPlusOffset(), + EdgeWeight{0} - source.GetForwardWeightPlusOffset(), source.forward_segment_id.id); } if (source.IsValidReverseSource()) { forward_heap.Insert(source.reverse_segment_id.id, - total_weight - source.GetReverseWeightPlusOffset(), + EdgeWeight{0} - source.GetReverseWeightPlusOffset(), source.reverse_segment_id.id); } } @@ -62,10 +61,10 @@ void searchWithUTurn(SearchEngineData &engine_working_data, facade, forward_heap, reverse_heap, - new_total_weight, + leg_weight, leg_packed_path, - getForwardLoopNodes(candidates), - getBackwardLoopNodes(candidates), + {}, + {}, candidates); } @@ -302,7 +301,7 @@ shortestPathWithWaypointUTurns(SearchEngineData &engine_working_data, PhantomEndpointCandidates search_candidates{waypoint_candidates[i], waypoint_candidates[i + 1]}; std::vector packed_leg; - EdgeWeight new_total_weight = INVALID_EDGE_WEIGHT; + EdgeWeight leg_weight = INVALID_EDGE_WEIGHT; // We have a valid path up to this leg BOOST_ASSERT(total_weight != INVALID_EDGE_WEIGHT); @@ -311,16 +310,15 @@ shortestPathWithWaypointUTurns(SearchEngineData &engine_working_data, forward_heap, reverse_heap, search_candidates, - total_weight, - new_total_weight, + leg_weight, packed_leg); - if (new_total_weight == INVALID_EDGE_WEIGHT) + if (leg_weight == INVALID_EDGE_WEIGHT) return {}; packed_leg_begin.push_back(total_packed_path.size()); total_packed_path.insert(total_packed_path.end(), packed_leg.begin(), packed_leg.end()); - total_weight = new_total_weight; + total_weight += leg_weight; }; // Add sentinel