Skip to content

Commit

Permalink
Remove force-loop checks for routes with u-turns (#6858)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjjbell authored May 5, 2024
1 parent d691af4 commit b503e96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
22 changes: 10 additions & 12 deletions include/engine/routing_algorithms/shortest_path_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ void searchWithUTurn(SearchEngineData<Algorithm> &engine_working_data,
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
typename SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
const PhantomEndpointCandidates &candidates,
const EdgeWeight &total_weight,
EdgeWeight &new_total_weight,
EdgeWeight &leg_weight,
std::vector<NodeID> &leg_packed_path)
{
forward_heap.Clear();
Expand All @@ -31,14 +30,14 @@ void searchWithUTurn(SearchEngineData<Algorithm> &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);
}
}
Expand All @@ -62,10 +61,10 @@ void searchWithUTurn(SearchEngineData<Algorithm> &engine_working_data,
facade,
forward_heap,
reverse_heap,
new_total_weight,
leg_weight,
leg_packed_path,
getForwardLoopNodes(candidates),
getBackwardLoopNodes(candidates),
{},
{},
candidates);
}

Expand Down Expand Up @@ -302,7 +301,7 @@ shortestPathWithWaypointUTurns(SearchEngineData<Algorithm> &engine_working_data,
PhantomEndpointCandidates search_candidates{waypoint_candidates[i],
waypoint_candidates[i + 1]};
std::vector<NodeID> 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);
Expand All @@ -311,16 +310,15 @@ shortestPathWithWaypointUTurns(SearchEngineData<Algorithm> &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
Expand Down

0 comments on commit b503e96

Please sign in to comment.