Refactor routing_algorithms to only contain free functions

This commit is contained in:
Patrick Niklaus
2017-02-25 01:24:21 +00:00
committed by Patrick Niklaus
parent 2fa8d0f534
commit 436b34ffea
20 changed files with 1481 additions and 1689 deletions
+2 -2
View File
@@ -208,8 +208,8 @@ Status MatchPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryData
// force uturns to be on, since we split the phantom nodes anyway and only have
// bi-directional
// phantom nodes for possible uturns
algorithms.ShortestRouting(
sub_routes[index].segment_end_coordinates, {false}, sub_routes[index]);
sub_routes[index] =
algorithms.ShortestRouting(sub_routes[index].segment_end_coordinates, {false});
BOOST_ASSERT(sub_routes[index].shortest_path_length != INVALID_EDGE_WEIGHT);
}
-1
View File
@@ -1,5 +1,4 @@
#include "engine/plugins/tile.hpp"
#include "engine/edge_unpacker.hpp"
#include "engine/plugins/plugin_base.hpp"
#include "util/coordinate_calculation.hpp"
+1 -1
View File
@@ -85,7 +85,7 @@ InternalRouteResult TripPlugin::ComputeRoute(const RoutingAlgorithmsInterface &a
BOOST_ASSERT(min_route.segment_end_coordinates.size() == trip.size() - 1);
}
algorithms.ShortestRouting(min_route.segment_end_coordinates, {false}, min_route);
min_route = algorithms.ShortestRouting(min_route.segment_end_coordinates, {false});
BOOST_ASSERT_MSG(min_route.shortest_path_length < INVALID_EDGE_WEIGHT, "unroutable route");
return min_route;
}
+4 -4
View File
@@ -89,17 +89,17 @@ ViaRoutePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFaca
{
if (route_parameters.alternatives && algorithms.HasAlternativeRouting())
{
algorithms.AlternativeRouting(raw_route.segment_end_coordinates.front(), raw_route);
raw_route = algorithms.AlternativeRouting(raw_route.segment_end_coordinates.front());
}
else
{
algorithms.DirectShortestPathRouting(raw_route.segment_end_coordinates, raw_route);
raw_route = algorithms.DirectShortestPathRouting(raw_route.segment_end_coordinates);
}
}
else
{
algorithms.ShortestRouting(
raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route);
raw_route = algorithms.ShortestRouting(raw_route.segment_end_coordinates,
route_parameters.continue_straight);
}
// we can only know this after the fact, different SCC ids still
File diff suppressed because it is too large Load Diff
@@ -1,5 +1,7 @@
#include "engine/routing_algorithms/direct_shortest_path.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
namespace osrm
{
namespace engine
@@ -13,11 +15,12 @@ namespace routing_algorithms
/// by the previous route.
/// This variation is only an optimazation for graphs with slow queries, for example
/// not fully contracted graphs.
void DirectShortestPathRouting<algorithm::CH>::
operator()(const FacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
InternalRouteResult &raw_route_data) const
InternalRouteResult directShortestPathSearch(
SearchEngineData &engine_working_data,
const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector)
{
InternalRouteResult raw_route_data;
// Get weight to next pair of target nodes.
BOOST_ASSERT_MSG(1 == phantom_nodes_vector.size(),
"Direct Shortest Path Query only accepts a single source and target pair. "
@@ -27,8 +30,8 @@ operator()(const FacadeT &facade,
const auto &target_phantom = phantom_node_pair.target_phantom;
engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes());
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
auto &forward_heap = *(engine_working_data.forward_heap_1);
auto &reverse_heap = *(engine_working_data.reverse_heap_1);
forward_heap.Clear();
reverse_heap.Clear();
@@ -71,30 +74,30 @@ operator()(const FacadeT &facade,
if (facade.GetCoreSize() > 0)
{
engine_working_data.InitializeOrClearSecondThreadLocalStorage(facade.GetNumberOfNodes());
QueryHeap &forward_core_heap = *(engine_working_data.forward_heap_2);
QueryHeap &reverse_core_heap = *(engine_working_data.reverse_heap_2);
auto &forward_core_heap = *(engine_working_data.forward_heap_2);
auto &reverse_core_heap = *(engine_working_data.reverse_heap_2);
forward_core_heap.Clear();
reverse_core_heap.Clear();
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
weight,
packed_leg,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
searchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
weight,
packed_leg,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
else
{
super::Search(facade,
forward_heap,
reverse_heap,
weight,
packed_leg,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
search(facade,
forward_heap,
reverse_heap,
weight,
packed_leg,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
// No path found for both target nodes?
@@ -102,7 +105,7 @@ operator()(const FacadeT &facade,
{
raw_route_data.shortest_path_length = INVALID_EDGE_WEIGHT;
raw_route_data.alternative_path_length = INVALID_EDGE_WEIGHT;
return;
return raw_route_data;
}
BOOST_ASSERT_MSG(!packed_leg.empty(), "packed path empty");
@@ -114,11 +117,13 @@ operator()(const FacadeT &facade,
raw_route_data.target_traversed_in_reverse.push_back(
(packed_leg.back() != phantom_node_pair.target_phantom.forward_segment_id.id));
super::UnpackPath(facade,
packed_leg.begin(),
packed_leg.end(),
phantom_node_pair,
raw_route_data.unpacked_path_segments.front());
unpackPath(facade,
packed_leg.begin(),
packed_leg.end(),
phantom_node_pair,
raw_route_data.unpacked_path_segments.front());
return raw_route_data;
}
} // namespace routing_algorithms
} // namespace engine
+176 -85
View File
@@ -1,4 +1,12 @@
#include "engine/routing_algorithms/many_to_many.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include <boost/assert.hpp>
#include <limits>
#include <memory>
#include <unordered_map>
#include <vector>
namespace osrm
{
@@ -7,11 +15,172 @@ namespace engine
namespace routing_algorithms
{
std::vector<EdgeWeight> ManyToManyRouting<algorithm::CH>::
operator()(const FacadeT &facade,
const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices) const
using QueryHeap = SearchEngineData::ManyToManyQueryHeap;
namespace
{
struct NodeBucket
{
unsigned target_id; // essentially a row in the weight matrix
EdgeWeight weight;
EdgeWeight duration;
NodeBucket(const unsigned target_id, const EdgeWeight weight, const EdgeWeight duration)
: target_id(target_id), weight(weight), duration(duration)
{
}
};
// FIXME This should be replaced by an std::unordered_multimap, though this needs benchmarking
using SearchSpaceWithBuckets = std::unordered_map<NodeID, std::vector<NodeBucket>>;
template <bool forward_direction>
void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const NodeID node,
const EdgeWeight weight,
const EdgeWeight duration,
QueryHeap &query_heap)
{
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade.GetEdgeData(edge);
const bool direction_flag = (forward_direction ? data.forward : data.backward);
if (direction_flag)
{
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
const EdgeWeight edge_duration = data.duration;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
const EdgeWeight to_weight = weight + edge_weight;
const EdgeWeight to_duration = duration + edge_duration;
// New Node discovered -> Add to Heap + Node Info Storage
if (!query_heap.WasInserted(to))
{
query_heap.Insert(to, to_weight, {node, to_duration});
}
// Found a shorter Path -> Update weight
else if (to_weight < query_heap.GetKey(to))
{
// new parent
query_heap.GetData(to) = {node, to_duration};
query_heap.DecreaseKey(to, to_weight);
}
}
}
}
// Stalling
template <bool forward_direction>
bool stallAtNode(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const NodeID node,
const EdgeWeight weight,
QueryHeap &query_heap)
{
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade.GetEdgeData(edge);
const bool reverse_flag = ((!forward_direction) ? data.forward : data.backward);
if (reverse_flag)
{
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.weight;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
if (query_heap.WasInserted(to))
{
if (query_heap.GetKey(to) + edge_weight < weight)
{
return true;
}
}
}
}
return false;
}
void ForwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const unsigned row_idx,
const unsigned number_of_targets,
QueryHeap &query_heap,
const SearchSpaceWithBuckets &search_space_with_buckets,
std::vector<EdgeWeight> &weights_table,
std::vector<EdgeWeight> &durations_table)
{
const NodeID node = query_heap.DeleteMin();
const EdgeWeight source_weight = query_heap.GetKey(node);
const EdgeWeight source_duration = query_heap.GetData(node).duration;
// check if each encountered node has an entry
const auto bucket_iterator = search_space_with_buckets.find(node);
// iterate bucket if there exists one
if (bucket_iterator != search_space_with_buckets.end())
{
const std::vector<NodeBucket> &bucket_list = bucket_iterator->second;
for (const NodeBucket &current_bucket : bucket_list)
{
// get target id from bucket entry
const unsigned column_idx = current_bucket.target_id;
const EdgeWeight target_weight = current_bucket.weight;
const EdgeWeight target_duration = current_bucket.duration;
auto &current_weight = weights_table[row_idx * number_of_targets + column_idx];
auto &current_duration = durations_table[row_idx * number_of_targets + column_idx];
// check if new weight is better
const EdgeWeight new_weight = source_weight + target_weight;
if (new_weight < 0)
{
const EdgeWeight loop_weight = getLoopWeight<false>(facade, node);
const EdgeWeight new_weight_with_loop = new_weight + loop_weight;
if (loop_weight != INVALID_EDGE_WEIGHT && new_weight_with_loop >= 0)
{
current_weight = std::min(current_weight, new_weight_with_loop);
current_duration = std::min(current_duration,
source_duration + target_duration +
getLoopWeight<true>(facade, node));
}
}
else if (new_weight < current_weight)
{
current_weight = new_weight;
current_duration = source_duration + target_duration;
}
}
}
if (stallAtNode<true>(facade, node, source_weight, query_heap))
{
return;
}
relaxOutgoingEdges<true>(facade, node, source_weight, source_duration, query_heap);
}
void backwardRoutingStep(
const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const unsigned column_idx,
QueryHeap &query_heap,
SearchSpaceWithBuckets &search_space_with_buckets)
{
const NodeID node = query_heap.DeleteMin();
const EdgeWeight target_weight = query_heap.GetKey(node);
const EdgeWeight target_duration = query_heap.GetData(node).duration;
// store settled nodes in search space bucket
search_space_with_buckets[node].emplace_back(column_idx, target_weight, target_duration);
if (stallAtNode<false>(facade, node, target_weight, query_heap))
{
return;
}
relaxOutgoingEdges<false>(facade, node, target_weight, target_duration, query_heap);
}
}
std::vector<EdgeWeight>
manyToManySearch(SearchEngineData &engine_working_data,
const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices)
{
const auto number_of_sources =
source_indices.empty() ? phantom_nodes.size() : source_indices.size();
@@ -24,7 +193,7 @@ operator()(const FacadeT &facade,
engine_working_data.InitializeOrClearManyToManyThreadLocalStorage(facade.GetNumberOfNodes());
QueryHeap &query_heap = *(engine_working_data.many_to_many_heap);
auto &query_heap = *(engine_working_data.many_to_many_heap);
SearchSpaceWithBuckets search_space_with_buckets;
@@ -49,7 +218,7 @@ operator()(const FacadeT &facade,
// explore search space
while (!query_heap.Empty())
{
BackwardRoutingStep(facade, column_idx, query_heap, search_space_with_buckets);
backwardRoutingStep(facade, column_idx, query_heap, search_space_with_buckets);
}
++column_idx;
};
@@ -122,84 +291,6 @@ operator()(const FacadeT &facade,
return durations_table;
}
void ManyToManyRouting<algorithm::CH>::ForwardRoutingStep(
const FacadeT &facade,
const unsigned row_idx,
const unsigned number_of_targets,
QueryHeap &query_heap,
const SearchSpaceWithBuckets &search_space_with_buckets,
std::vector<EdgeWeight> &weights_table,
std::vector<EdgeWeight> &durations_table) const
{
const NodeID node = query_heap.DeleteMin();
const EdgeWeight source_weight = query_heap.GetKey(node);
const EdgeWeight source_duration = query_heap.GetData(node).duration;
// check if each encountered node has an entry
const auto bucket_iterator = search_space_with_buckets.find(node);
// iterate bucket if there exists one
if (bucket_iterator != search_space_with_buckets.end())
{
const std::vector<NodeBucket> &bucket_list = bucket_iterator->second;
for (const NodeBucket &current_bucket : bucket_list)
{
// get target id from bucket entry
const unsigned column_idx = current_bucket.target_id;
const EdgeWeight target_weight = current_bucket.weight;
const EdgeWeight target_duration = current_bucket.duration;
auto &current_weight = weights_table[row_idx * number_of_targets + column_idx];
auto &current_duration = durations_table[row_idx * number_of_targets + column_idx];
// check if new weight is better
const EdgeWeight new_weight = source_weight + target_weight;
if (new_weight < 0)
{
const EdgeWeight loop_weight = super::GetLoopWeight<false>(facade, node);
const EdgeWeight new_weight_with_loop = new_weight + loop_weight;
if (loop_weight != INVALID_EDGE_WEIGHT && new_weight_with_loop >= 0)
{
current_weight = std::min(current_weight, new_weight_with_loop);
current_duration = std::min(current_duration,
source_duration + target_duration +
super::GetLoopWeight<true>(facade, node));
}
}
else if (new_weight < current_weight)
{
current_weight = new_weight;
current_duration = source_duration + target_duration;
}
}
}
if (StallAtNode<true>(facade, node, source_weight, query_heap))
{
return;
}
RelaxOutgoingEdges<true>(facade, node, source_weight, source_duration, query_heap);
}
void ManyToManyRouting<algorithm::CH>::BackwardRoutingStep(
const FacadeT &facade,
const unsigned column_idx,
QueryHeap &query_heap,
SearchSpaceWithBuckets &search_space_with_buckets) const
{
const NodeID node = query_heap.DeleteMin();
const EdgeWeight target_weight = query_heap.GetKey(node);
const EdgeWeight target_duration = query_heap.GetData(node).duration;
// store settled nodes in search space bucket
search_space_with_buckets[node].emplace_back(column_idx, target_weight, target_duration);
if (StallAtNode<false>(facade, node, target_weight, query_heap))
{
return;
}
RelaxOutgoingEdges<false>(facade, node, target_weight, target_duration, query_heap);
}
} // namespace routing_algorithms
} // namespace engine
} // namespace osrm
+51 -22
View File
@@ -1,4 +1,20 @@
#include "engine/routing_algorithms/map_matching.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/map_matching/hidden_markov_model.hpp"
#include "engine/map_matching/matching_confidence.hpp"
#include "engine/map_matching/sub_matching.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/for_each_pair.hpp"
#include <algorithm>
#include <cstddef>
#include <deque>
#include <iomanip>
#include <memory>
#include <numeric>
#include <utility>
namespace osrm
{
@@ -7,8 +23,15 @@ namespace engine
namespace routing_algorithms
{
unsigned
MapMatching<algorithm::CH>::GetMedianSampleTime(const std::vector<unsigned> &timestamps) const
namespace
{
using HMM = map_matching::HiddenMarkovModel<CandidateLists>;
constexpr static const unsigned MAX_BROKEN_STATES = 10;
constexpr static const double MATCHING_BETA = 10;
constexpr static const double MAX_DISTANCE_DELTA = 2000.;
unsigned getMedianSampleTime(const std::vector<unsigned> &timestamps)
{
BOOST_ASSERT(timestamps.size() > 1);
@@ -22,14 +45,20 @@ MapMatching<algorithm::CH>::GetMedianSampleTime(const std::vector<unsigned> &tim
std::nth_element(first_elem, median, sample_times.end());
return *median;
}
}
SubMatchingList MapMatching<algorithm::CH>::
operator()(const FacadeT &facade,
const CandidateLists &candidates_list,
const std::vector<util::Coordinate> &trace_coordinates,
const std::vector<unsigned> &trace_timestamps,
const std::vector<boost::optional<double>> &trace_gps_precision) const
SubMatchingList
mapMatching(SearchEngineData &engine_working_data,
const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const CandidateLists &candidates_list,
const std::vector<util::Coordinate> &trace_coordinates,
const std::vector<unsigned> &trace_timestamps,
const std::vector<boost::optional<double>> &trace_gps_precision)
{
map_matching::MatchingConfidence confidence;
map_matching::EmissionLogProbability default_emission_log_probability(DEFAULT_GPS_PRECISION);
map_matching::TransitionLogProbability transition_log_probability(MATCHING_BETA);
SubMatchingList sub_matchings;
BOOST_ASSERT(candidates_list.size() == trace_coordinates.size());
@@ -40,7 +69,7 @@ operator()(const FacadeT &facade,
const auto median_sample_time = [&] {
if (use_timestamps)
{
return std::max(1u, GetMedianSampleTime(trace_timestamps));
return std::max(1u, getMedianSampleTime(trace_timestamps));
}
else
{
@@ -68,7 +97,7 @@ operator()(const FacadeT &facade,
std::transform(candidates_list[t].begin(),
candidates_list[t].end(),
emission_log_probabilities[t].begin(),
[this](const PhantomNodeWithDistance &candidate) {
[&](const PhantomNodeWithDistance &candidate) {
return default_emission_log_probability(candidate.distance);
});
}
@@ -95,7 +124,7 @@ operator()(const FacadeT &facade,
std::transform(candidates_list[t].begin(),
candidates_list[t].end(),
emission_log_probabilities[t].begin(),
[this](const PhantomNodeWithDistance &candidate) {
[&](const PhantomNodeWithDistance &candidate) {
return default_emission_log_probability(candidate.distance);
});
}
@@ -113,10 +142,10 @@ operator()(const FacadeT &facade,
engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade.GetNumberOfNodes());
engine_working_data.InitializeOrClearSecondThreadLocalStorage(facade.GetNumberOfNodes());
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
QueryHeap &forward_core_heap = *(engine_working_data.forward_heap_2);
QueryHeap &reverse_core_heap = *(engine_working_data.reverse_heap_2);
auto &forward_heap = *(engine_working_data.forward_heap_1);
auto &reverse_heap = *(engine_working_data.reverse_heap_1);
auto &forward_core_heap = *(engine_working_data.forward_heap_2);
auto &reverse_core_heap = *(engine_working_data.reverse_heap_2);
std::size_t breakage_begin = map_matching::INVALID_STATE;
std::vector<std::size_t> split_points;
@@ -187,7 +216,7 @@ operator()(const FacadeT &facade,
{
forward_core_heap.Clear();
reverse_core_heap.Clear();
network_distance = super::GetNetworkDistanceWithCore(
network_distance = getNetworkDistanceWithCore(
facade,
forward_heap,
reverse_heap,
@@ -199,12 +228,12 @@ operator()(const FacadeT &facade,
}
else
{
network_distance = super::GetNetworkDistance(
facade,
forward_heap,
reverse_heap,
prev_unbroken_timestamps_list[s].phantom_node,
current_timestamps_list[s_prime].phantom_node);
network_distance =
getNetworkDistance(facade,
forward_heap,
reverse_heap,
prev_unbroken_timestamps_list[s].phantom_node,
current_timestamps_list[s_prime].phantom_node);
}
// get distance diff between loc1/2 and locs/s_prime
+82 -86
View File
@@ -7,16 +7,16 @@ namespace engine
namespace routing_algorithms
{
void BasicRouting<algorithm::CH>::RoutingStep(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
NodeID &middle_node_id,
EdgeWeight &upper_bound,
EdgeWeight min_edge_offset,
const bool forward_direction,
const bool stalling,
const bool force_loop_forward,
const bool force_loop_reverse) const
void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
NodeID &middle_node_id,
EdgeWeight &upper_bound,
EdgeWeight min_edge_offset,
const bool forward_direction,
const bool stalling,
const bool force_loop_forward,
const bool force_loop_reverse)
{
const NodeID node = forward_heap.DeleteMin();
const EdgeWeight weight = forward_heap.GetKey(node);
@@ -36,7 +36,7 @@ void BasicRouting<algorithm::CH>::RoutingStep(const FacadeT &facade,
// check whether there is a loop present at the node
for (const auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade.GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
bool forward_directionFlag = (forward_direction ? data.forward : data.backward);
if (forward_directionFlag)
{
@@ -78,7 +78,7 @@ void BasicRouting<algorithm::CH>::RoutingStep(const FacadeT &facade,
{
for (const auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade.GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
const bool reverse_flag = ((!forward_direction) ? data.forward : data.backward);
if (reverse_flag)
{
@@ -100,7 +100,7 @@ void BasicRouting<algorithm::CH>::RoutingStep(const FacadeT &facade,
for (const auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade.GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
bool forward_directionFlag = (forward_direction ? data.forward : data.backward);
if (forward_directionFlag)
{
@@ -133,38 +133,35 @@ void BasicRouting<algorithm::CH>::RoutingStep(const FacadeT &facade,
* @param to the node the CH edge finishes at
* @param unpacked_path the sequence of original NodeIDs that make up the expanded CH edge
*/
void BasicRouting<algorithm::CH>::UnpackEdge(const FacadeT &facade,
const NodeID from,
const NodeID to,
std::vector<NodeID> &unpacked_path) const
void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const NodeID from,
const NodeID to,
std::vector<NodeID> &unpacked_path)
{
std::array<NodeID, 2> path{{from, to}};
UnpackCHPath(
facade,
path.begin(),
path.end(),
[&unpacked_path](const std::pair<NodeID, NodeID> &edge, const EdgeData & /* data */) {
unpacked_path.emplace_back(edge.first);
});
unpackPath(facade,
path.begin(),
path.end(),
[&unpacked_path](const std::pair<NodeID, NodeID> &edge, const auto & /* data */) {
unpacked_path.emplace_back(edge.first);
});
unpacked_path.emplace_back(to);
}
void BasicRouting<algorithm::CH>::RetrievePackedPathFromHeap(
const SearchEngineData::QueryHeap &forward_heap,
const SearchEngineData::QueryHeap &reverse_heap,
const NodeID middle_node_id,
std::vector<NodeID> &packed_path) const
void retrievePackedPathFromHeap(const SearchEngineData::QueryHeap &forward_heap,
const SearchEngineData::QueryHeap &reverse_heap,
const NodeID middle_node_id,
std::vector<NodeID> &packed_path)
{
RetrievePackedPathFromSingleHeap(forward_heap, middle_node_id, packed_path);
retrievePackedPathFromSingleHeap(forward_heap, middle_node_id, packed_path);
std::reverse(packed_path.begin(), packed_path.end());
packed_path.emplace_back(middle_node_id);
RetrievePackedPathFromSingleHeap(reverse_heap, middle_node_id, packed_path);
retrievePackedPathFromSingleHeap(reverse_heap, middle_node_id, packed_path);
}
void BasicRouting<algorithm::CH>::RetrievePackedPathFromSingleHeap(
const SearchEngineData::QueryHeap &search_heap,
const NodeID middle_node_id,
std::vector<NodeID> &packed_path) const
void retrievePackedPathFromSingleHeap(const SearchEngineData::QueryHeap &search_heap,
const NodeID middle_node_id,
std::vector<NodeID> &packed_path)
{
NodeID current_node_id = middle_node_id;
// all initial nodes will have itself as parent, or a node not in the heap
@@ -191,14 +188,14 @@ void BasicRouting<algorithm::CH>::RetrievePackedPathFromSingleHeap(
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void BasicRouting<algorithm::CH>::Search(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
EdgeWeight &weight,
std::vector<NodeID> &packed_leg,
const bool force_loop_forward,
const bool force_loop_reverse,
const EdgeWeight weight_upper_bound) const
void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
EdgeWeight &weight,
std::vector<NodeID> &packed_leg,
const bool force_loop_forward,
const bool force_loop_reverse,
const EdgeWeight weight_upper_bound)
{
NodeID middle = SPECIAL_NODEID;
weight = weight_upper_bound;
@@ -215,7 +212,7 @@ void BasicRouting<algorithm::CH>::Search(const FacadeT &facade,
{
if (!forward_heap.Empty())
{
RoutingStep(facade,
routingStep(facade,
forward_heap,
reverse_heap,
middle,
@@ -228,7 +225,7 @@ void BasicRouting<algorithm::CH>::Search(const FacadeT &facade,
}
if (!reverse_heap.Empty())
{
RoutingStep(facade,
routingStep(facade,
reverse_heap,
forward_heap,
middle,
@@ -260,7 +257,7 @@ void BasicRouting<algorithm::CH>::Search(const FacadeT &facade,
}
else
{
RetrievePackedPathFromHeap(forward_heap, reverse_heap, middle, packed_leg);
retrievePackedPathFromHeap(forward_heap, reverse_heap, middle, packed_leg);
}
}
@@ -273,16 +270,16 @@ void BasicRouting<algorithm::CH>::Search(const FacadeT &facade,
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
EdgeWeight &weight,
std::vector<NodeID> &packed_leg,
const bool force_loop_forward,
const bool force_loop_reverse,
EdgeWeight weight_upper_bound) const
void searchWithCore(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
EdgeWeight &weight,
std::vector<NodeID> &packed_leg,
const bool force_loop_forward,
const bool force_loop_reverse,
EdgeWeight weight_upper_bound)
{
NodeID middle = SPECIAL_NODEID;
weight = weight_upper_bound;
@@ -310,7 +307,7 @@ void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
}
else
{
RoutingStep(facade,
routingStep(facade,
forward_heap,
reverse_heap,
middle,
@@ -332,7 +329,7 @@ void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
}
else
{
RoutingStep(facade,
routingStep(facade,
reverse_heap,
forward_heap,
middle,
@@ -385,7 +382,7 @@ void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() &&
weight > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
{
RoutingStep(facade,
routingStep(facade,
forward_core_heap,
reverse_core_heap,
middle,
@@ -396,7 +393,7 @@ void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
force_loop_forward,
force_loop_reverse);
RoutingStep(facade,
routingStep(facade,
reverse_core_heap,
forward_core_heap,
middle,
@@ -432,13 +429,13 @@ void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
else
{
std::vector<NodeID> packed_core_leg;
RetrievePackedPathFromHeap(
retrievePackedPathFromHeap(
forward_core_heap, reverse_core_heap, middle, packed_core_leg);
BOOST_ASSERT(packed_core_leg.size() > 0);
RetrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg);
retrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg);
std::reverse(packed_leg.begin(), packed_leg.end());
packed_leg.insert(packed_leg.end(), packed_core_leg.begin(), packed_core_leg.end());
RetrievePackedPathFromSingleHeap(reverse_heap, packed_core_leg.back(), packed_leg);
retrievePackedPathFromSingleHeap(reverse_heap, packed_core_leg.back(), packed_leg);
}
}
else
@@ -453,13 +450,12 @@ void BasicRouting<algorithm::CH>::SearchWithCore(const FacadeT &facade,
}
else
{
RetrievePackedPathFromHeap(forward_heap, reverse_heap, middle, packed_leg);
retrievePackedPathFromHeap(forward_heap, reverse_heap, middle, packed_leg);
}
}
}
bool BasicRouting<algorithm::CH>::NeedsLoopForward(const PhantomNode &source_phantom,
const PhantomNode &target_phantom) const
bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom)
{
return source_phantom.forward_segment_id.enabled && target_phantom.forward_segment_id.enabled &&
source_phantom.forward_segment_id.id == target_phantom.forward_segment_id.id &&
@@ -467,8 +463,7 @@ bool BasicRouting<algorithm::CH>::NeedsLoopForward(const PhantomNode &source_pha
target_phantom.GetForwardWeightPlusOffset();
}
bool BasicRouting<algorithm::CH>::NeedsLoopBackwards(const PhantomNode &source_phantom,
const PhantomNode &target_phantom) const
bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &target_phantom)
{
return source_phantom.reverse_segment_id.enabled && target_phantom.reverse_segment_id.enabled &&
source_phantom.reverse_segment_id.id == target_phantom.reverse_segment_id.id &&
@@ -476,16 +471,16 @@ bool BasicRouting<algorithm::CH>::NeedsLoopBackwards(const PhantomNode &source_p
target_phantom.GetReverseWeightPlusOffset();
}
double BasicRouting<algorithm::CH>::GetPathDistance(const FacadeT &facade,
const std::vector<NodeID> &packed_path,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom) const
double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const std::vector<NodeID> &packed_path,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom)
{
std::vector<PathData> unpacked_path;
PhantomNodes nodes;
nodes.source_phantom = source_phantom;
nodes.target_phantom = target_phantom;
UnpackPath(facade, packed_path.begin(), packed_path.end(), nodes, unpacked_path);
unpackPath(facade, packed_path.begin(), packed_path.end(), nodes, unpacked_path);
using util::coordinate_calculation::detail::DEGREE_TO_RAD;
using util::coordinate_calculation::detail::EARTH_RADIUS;
@@ -535,15 +530,15 @@ double BasicRouting<algorithm::CH>::GetPathDistance(const FacadeT &facade,
// Requires the heaps for be empty
// If heaps should be adjusted to be initialized outside of this function,
// the addition of force_loop parameters might be required
double BasicRouting<algorithm::CH>::GetNetworkDistanceWithCore(
const FacadeT &facade,
double getNetworkDistanceWithCore(
const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
EdgeWeight weight_upper_bound) const
EdgeWeight weight_upper_bound)
{
BOOST_ASSERT(forward_heap.Empty());
BOOST_ASSERT(reverse_heap.Empty());
@@ -579,7 +574,7 @@ double BasicRouting<algorithm::CH>::GetNetworkDistanceWithCore(
EdgeWeight weight = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_path;
SearchWithCore(facade,
searchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
@@ -593,7 +588,7 @@ double BasicRouting<algorithm::CH>::GetNetworkDistanceWithCore(
double distance = std::numeric_limits<double>::max();
if (weight != INVALID_EDGE_WEIGHT)
{
return GetPathDistance(facade, packed_path, source_phantom, target_phantom);
return getPathDistance(facade, packed_path, source_phantom, target_phantom);
}
return distance;
}
@@ -601,12 +596,13 @@ double BasicRouting<algorithm::CH>::GetNetworkDistanceWithCore(
// Requires the heaps for be empty
// If heaps should be adjusted to be initialized outside of this function,
// the addition of force_loop parameters might be required
double BasicRouting<algorithm::CH>::GetNetworkDistance(const FacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
EdgeWeight weight_upper_bound) const
double
getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
EdgeWeight weight_upper_bound)
{
BOOST_ASSERT(forward_heap.Empty());
BOOST_ASSERT(reverse_heap.Empty());
@@ -642,7 +638,7 @@ double BasicRouting<algorithm::CH>::GetNetworkDistance(const FacadeT &facade,
EdgeWeight weight = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_path;
Search(facade,
search(facade,
forward_heap,
reverse_heap,
weight,
@@ -656,7 +652,7 @@ double BasicRouting<algorithm::CH>::GetNetworkDistance(const FacadeT &facade,
return std::numeric_limits<double>::max();
}
return GetPathDistance(facade, packed_path, source_phantom, target_phantom);
return getPathDistance(facade, packed_path, source_phantom, target_phantom);
}
} // namespace routing_algorithms
+113 -104
View File
@@ -1,4 +1,9 @@
#include "engine/routing_algorithms/shortest_path.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <memory>
namespace osrm
{
@@ -7,23 +12,26 @@ namespace engine
namespace routing_algorithms
{
const static constexpr bool DO_NOT_FORCE_LOOP = false;
using QueryHeap = SearchEngineData::QueryHeap;
// allows a uturn at the target_phantom
// searches source forward/reverse -> target forward/reverse
void ShortestPathRouting<algorithm::CH>::SearchWithUTurn(const FacadeT &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
QueryHeap &reverse_core_heap,
const bool search_from_forward_node,
const bool search_from_reverse_node,
const bool search_to_forward_node,
const bool search_to_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_weight_to_forward,
const int total_weight_to_reverse,
int &new_total_weight,
std::vector<NodeID> &leg_packed_path) const
void searchWithUTurn(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
QueryHeap &reverse_core_heap,
const bool search_from_forward_node,
const bool search_from_reverse_node,
const bool search_to_forward_node,
const bool search_to_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_weight_to_forward,
const int total_weight_to_reverse,
int &new_total_weight,
std::vector<NodeID> &leg_packed_path)
{
forward_heap.Clear();
reverse_heap.Clear();
@@ -59,35 +67,34 @@ void ShortestPathRouting<algorithm::CH>::SearchWithUTurn(const FacadeT &facade,
auto is_oneway_source = !(search_from_forward_node && search_from_reverse_node);
auto is_oneway_target = !(search_to_forward_node && search_to_reverse_node);
// we only enable loops here if we can't search from forward to backward node
auto needs_loop_forwad =
is_oneway_source && super::NeedsLoopForward(source_phantom, target_phantom);
auto needs_loop_forwad = is_oneway_source && needsLoopForward(source_phantom, target_phantom);
auto needs_loop_backwards =
is_oneway_target && super::NeedsLoopBackwards(source_phantom, target_phantom);
is_oneway_target && needsLoopBackwards(source_phantom, target_phantom);
if (facade.GetCoreSize() > 0)
{
forward_core_heap.Clear();
reverse_core_heap.Clear();
BOOST_ASSERT(forward_core_heap.Size() == 0);
BOOST_ASSERT(reverse_core_heap.Size() == 0);
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_weight,
leg_packed_path,
needs_loop_forwad,
needs_loop_backwards);
searchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_weight,
leg_packed_path,
needs_loop_forwad,
needs_loop_backwards);
}
else
{
super::Search(facade,
forward_heap,
reverse_heap,
new_total_weight,
leg_packed_path,
needs_loop_forwad,
needs_loop_backwards);
search(facade,
forward_heap,
reverse_heap,
new_total_weight,
leg_packed_path,
needs_loop_forwad,
needs_loop_backwards);
}
// if no route is found between two parts of the via-route, the entire route becomes
// invalid. Adding to invalid edge weight sadly doesn't return an invalid edge weight. Here
@@ -99,23 +106,23 @@ void ShortestPathRouting<algorithm::CH>::SearchWithUTurn(const FacadeT &facade,
// searches shortest path between:
// source forward/reverse -> target forward
// source forward/reverse -> target reverse
void ShortestPathRouting<algorithm::CH>::Search(const FacadeT &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
QueryHeap &reverse_core_heap,
const bool search_from_forward_node,
const bool search_from_reverse_node,
const bool search_to_forward_node,
const bool search_to_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_weight_to_forward,
const int total_weight_to_reverse,
int &new_total_weight_to_forward,
int &new_total_weight_to_reverse,
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse) const
void Search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
QueryHeap &reverse_core_heap,
const bool search_from_forward_node,
const bool search_from_reverse_node,
const bool search_to_forward_node,
const bool search_to_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_weight_to_forward,
const int total_weight_to_reverse,
int &new_total_weight_to_forward,
int &new_total_weight_to_reverse,
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse)
{
if (search_to_forward_node)
{
@@ -148,25 +155,25 @@ void ShortestPathRouting<algorithm::CH>::Search(const FacadeT &facade,
reverse_core_heap.Clear();
BOOST_ASSERT(forward_core_heap.Size() == 0);
BOOST_ASSERT(reverse_core_heap.Size() == 0);
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_weight_to_forward,
leg_packed_path_forward,
super::NeedsLoopForward(source_phantom, target_phantom),
DO_NOT_FORCE_LOOP);
searchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_weight_to_forward,
leg_packed_path_forward,
needsLoopForward(source_phantom, target_phantom),
DO_NOT_FORCE_LOOP);
}
else
{
super::Search(facade,
forward_heap,
reverse_heap,
new_total_weight_to_forward,
leg_packed_path_forward,
super::NeedsLoopForward(source_phantom, target_phantom),
DO_NOT_FORCE_LOOP);
search(facade,
forward_heap,
reverse_heap,
new_total_weight_to_forward,
leg_packed_path_forward,
needsLoopForward(source_phantom, target_phantom),
DO_NOT_FORCE_LOOP);
}
}
@@ -199,36 +206,35 @@ void ShortestPathRouting<algorithm::CH>::Search(const FacadeT &facade,
reverse_core_heap.Clear();
BOOST_ASSERT(forward_core_heap.Size() == 0);
BOOST_ASSERT(reverse_core_heap.Size() == 0);
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_weight_to_reverse,
leg_packed_path_reverse,
DO_NOT_FORCE_LOOP,
super::NeedsLoopBackwards(source_phantom, target_phantom));
searchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_weight_to_reverse,
leg_packed_path_reverse,
DO_NOT_FORCE_LOOP,
needsLoopBackwards(source_phantom, target_phantom));
}
else
{
super::Search(facade,
forward_heap,
reverse_heap,
new_total_weight_to_reverse,
leg_packed_path_reverse,
DO_NOT_FORCE_LOOP,
super::NeedsLoopBackwards(source_phantom, target_phantom));
search(facade,
forward_heap,
reverse_heap,
new_total_weight_to_reverse,
leg_packed_path_reverse,
DO_NOT_FORCE_LOOP,
needsLoopBackwards(source_phantom, target_phantom));
}
}
}
void ShortestPathRouting<algorithm::CH>::UnpackLegs(
const FacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const std::vector<NodeID> &total_packed_path,
const std::vector<std::size_t> &packed_leg_begin,
const int shortest_path_length,
InternalRouteResult &raw_route_data) const
void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const std::vector<NodeID> &total_packed_path,
const std::vector<std::size_t> &packed_leg_begin,
const int shortest_path_length,
InternalRouteResult &raw_route_data)
{
raw_route_data.unpacked_path_segments.resize(packed_leg_begin.size() - 1);
@@ -239,11 +245,11 @@ void ShortestPathRouting<algorithm::CH>::UnpackLegs(
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
const auto &unpack_phantom_node_pair = phantom_nodes_vector[current_leg];
super::UnpackPath(facade,
leg_begin,
leg_end,
unpack_phantom_node_pair,
raw_route_data.unpacked_path_segments[current_leg]);
unpackPath(facade,
leg_begin,
leg_end,
unpack_phantom_node_pair,
raw_route_data.unpacked_path_segments[current_leg]);
raw_route_data.source_traversed_in_reverse.push_back(
(*leg_begin != phantom_nodes_vector[current_leg].source_phantom.forward_segment_id.id));
@@ -253,12 +259,13 @@ void ShortestPathRouting<algorithm::CH>::UnpackLegs(
}
}
void ShortestPathRouting<algorithm::CH>::
operator()(const FacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const boost::optional<bool> continue_straight_at_waypoint,
InternalRouteResult &raw_route_data) const
InternalRouteResult
shortestPathSearch(SearchEngineData &engine_working_data,
const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const boost::optional<bool> continue_straight_at_waypoint)
{
InternalRouteResult raw_route_data;
const bool allow_uturn_at_waypoint =
!(continue_straight_at_waypoint ? *continue_straight_at_waypoint
: facade.GetContinueStraightDefault());
@@ -312,7 +319,7 @@ operator()(const FacadeT &facade,
{
if (allow_uturn_at_waypoint)
{
SearchWithUTurn(facade,
searchWithUTurn(facade,
forward_heap,
reverse_heap,
forward_core_heap,
@@ -370,7 +377,7 @@ operator()(const FacadeT &facade,
{
raw_route_data.shortest_path_length = INVALID_EDGE_WEIGHT;
raw_route_data.alternative_path_length = INVALID_EDGE_WEIGHT;
return;
return raw_route_data;
}
// we need to figure out how the new legs connect to the previous ones
@@ -473,7 +480,7 @@ operator()(const FacadeT &facade,
packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size());
BOOST_ASSERT(packed_leg_to_reverse_begin.size() == phantom_nodes_vector.size() + 1);
UnpackLegs(facade,
unpackLegs(facade,
phantom_nodes_vector,
total_packed_path_to_reverse,
packed_leg_to_reverse_begin,
@@ -486,13 +493,15 @@ operator()(const FacadeT &facade,
packed_leg_to_forward_begin.push_back(total_packed_path_to_forward.size());
BOOST_ASSERT(packed_leg_to_forward_begin.size() == phantom_nodes_vector.size() + 1);
UnpackLegs(facade,
unpackLegs(facade,
phantom_nodes_vector,
total_packed_path_to_forward,
packed_leg_to_forward_begin,
total_weight_to_forward,
raw_route_data);
}
return raw_route_data;
}
} // namespace routing_algorithms
+4 -4
View File
@@ -7,10 +7,10 @@ namespace engine
namespace routing_algorithms
{
std::vector<TurnData> TileTurns<algorithm::CH>::
operator()(const FacadeT &facade,
const std::vector<RTreeLeaf> &edges,
const std::vector<std::size_t> &sorted_edge_indexes) const
std::vector<TurnData>
getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
const std::vector<RTreeLeaf> &edges,
const std::vector<std::size_t> &sorted_edge_indexes)
{
std::vector<TurnData> all_turn_data;