Make DataFacade local to every request

This is the first step to having fine grained locking on data updates,
see issue #2570.
This commit is contained in:
Patrick Niklaus
2016-10-06 01:05:03 +02:00
committed by Patrick Niklaus
parent 66f2cc5184
commit 1c2ead8fb8
21 changed files with 361 additions and 291 deletions
@@ -50,18 +50,19 @@ class AlternativeRouting final
return (2 * length + sharing) < (2 * other.length + other.sharing);
}
};
DataFacadeT *facade;
SearchEngineData &engine_working_data;
public:
AlternativeRouting(DataFacadeT *facade, SearchEngineData &engine_working_data)
: super(facade), facade(facade), engine_working_data(engine_working_data)
AlternativeRouting(SearchEngineData &engine_working_data)
: engine_working_data(engine_working_data)
{
}
virtual ~AlternativeRouting() {}
void operator()(const PhantomNodes &phantom_node_pair, InternalRouteResult &raw_route_data)
void operator()(const DataFacadeT &facade,
const PhantomNodes &phantom_node_pair,
InternalRouteResult &raw_route_data)
{
std::vector<NodeID> alternative_path;
std::vector<NodeID> via_node_candidate_list;
@@ -70,11 +71,11 @@ class AlternativeRouting final
// Init queues, semi-expensive because access to TSS invokes a sys-call
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
engine_working_data.InitializeOrClearThirdThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &forward_heap1 = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap1 = *(engine_working_data.reverse_heap_1);
@@ -130,7 +131,8 @@ class AlternativeRouting final
{
if (0 < forward_heap1.Size())
{
AlternativeRoutingStep<true>(forward_heap1,
AlternativeRoutingStep<true>(facade,
forward_heap1,
reverse_heap1,
&middle_node,
&upper_bound_to_shortest_path_distance,
@@ -140,7 +142,8 @@ class AlternativeRouting final
}
if (0 < reverse_heap1.Size())
{
AlternativeRoutingStep<false>(forward_heap1,
AlternativeRoutingStep<false>(facade,
forward_heap1,
reverse_heap1,
&middle_node,
&upper_bound_to_shortest_path_distance,
@@ -286,7 +289,8 @@ class AlternativeRouting final
for (const NodeID node : preselected_node_list)
{
int length_of_via_path = 0, sharing_of_via_path = 0;
ComputeLengthAndSharingOfViaPath(node,
ComputeLengthAndSharingOfViaPath(facade,
node,
&length_of_via_path,
&sharing_of_via_path,
packed_shortest_path,
@@ -306,7 +310,8 @@ class AlternativeRouting final
NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID;
for (const RankedCandidateNode &candidate : ranked_candidates_list)
{
if (ViaNodeCandidatePassesTTest(forward_heap1,
if (ViaNodeCandidatePassesTTest(facade,
forward_heap1,
reverse_heap1,
forward_heap2,
reverse_heap2,
@@ -336,6 +341,7 @@ class AlternativeRouting final
phantom_node_pair.target_phantom.forward_segment_id.id));
super::UnpackPath(
facade,
// -- packed input
packed_shortest_path.begin(),
packed_shortest_path.end(),
@@ -366,7 +372,8 @@ class AlternativeRouting final
phantom_node_pair.target_phantom.forward_segment_id.id));
// unpack the alternate path
super::UnpackPath(packed_alternate_path.begin(),
super::UnpackPath(facade,
packed_alternate_path.begin(),
packed_alternate_path.end(),
phantom_node_pair,
raw_route_data.unpacked_alternative);
@@ -405,14 +412,15 @@ class AlternativeRouting final
// compute and unpack <s,..,v> and <v,..,t> by exploring search spaces
// from v and intersecting against queues. only half-searches have to be
// done at this stage
void ComputeLengthAndSharingOfViaPath(const NodeID via_node,
void ComputeLengthAndSharingOfViaPath(const DataFacadeT& facade,
const NodeID via_node,
int *real_length_of_via_path,
int *sharing_of_via_path,
const std::vector<NodeID> &packed_shortest_path,
const EdgeWeight min_edge_offset)
{
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &existing_forward_heap = *engine_working_data.forward_heap_1;
QueryHeap &existing_reverse_heap = *engine_working_data.reverse_heap_1;
@@ -433,7 +441,8 @@ class AlternativeRouting final
const bool constexpr DO_NOT_FORCE_LOOPS = false;
while (!new_reverse_heap.Empty())
{
super::RoutingStep(new_reverse_heap,
super::RoutingStep(facade,
new_reverse_heap,
existing_forward_heap,
s_v_middle,
upper_bound_s_v_path_length,
@@ -449,7 +458,8 @@ class AlternativeRouting final
new_forward_heap.Insert(via_node, 0, via_node);
while (!new_forward_heap.Empty())
{
super::RoutingStep(new_forward_heap,
super::RoutingStep(facade,
new_forward_heap,
existing_reverse_heap,
v_t_middle,
upper_bound_of_v_t_path_length,
@@ -481,18 +491,20 @@ class AlternativeRouting final
if (packed_s_v_path[current_node] == packed_shortest_path[current_node] &&
packed_s_v_path[current_node + 1] == packed_shortest_path[current_node + 1])
{
EdgeID edgeID = facade->FindEdgeInEitherDirection(
EdgeID edgeID = facade.FindEdgeInEitherDirection(
packed_s_v_path[current_node], packed_s_v_path[current_node + 1]);
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
*sharing_of_via_path += facade.GetEdgeData(edgeID).distance;
}
else
{
if (packed_s_v_path[current_node] == packed_shortest_path[current_node])
{
super::UnpackEdge(packed_s_v_path[current_node],
super::UnpackEdge(facade,
packed_s_v_path[current_node],
packed_s_v_path[current_node + 1],
partially_unpacked_via_path);
super::UnpackEdge(packed_shortest_path[current_node],
super::UnpackEdge(facade,
packed_shortest_path[current_node],
packed_shortest_path[current_node + 1],
partially_unpacked_shortest_path);
break;
@@ -512,9 +524,9 @@ class AlternativeRouting final
++current_node)
{
EdgeID selected_edge =
facade->FindEdgeInEitherDirection(partially_unpacked_via_path[current_node],
facade.FindEdgeInEitherDirection(partially_unpacked_via_path[current_node],
partially_unpacked_via_path[current_node + 1]);
*sharing_of_via_path += facade->GetEdgeData(selected_edge).distance;
*sharing_of_via_path += facade.GetEdgeData(selected_edge).distance;
}
// Second, partially unpack v-->t in reverse order until paths deviate and note lengths
@@ -527,18 +539,20 @@ class AlternativeRouting final
packed_shortest_path[shortest_path_index - 1] &&
packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index])
{
EdgeID edgeID = facade->FindEdgeInEitherDirection(
EdgeID edgeID = facade.FindEdgeInEitherDirection(
packed_v_t_path[via_path_index - 1], packed_v_t_path[via_path_index]);
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
*sharing_of_via_path += facade.GetEdgeData(edgeID).distance;
}
else
{
if (packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index])
{
super::UnpackEdge(packed_v_t_path[via_path_index - 1],
super::UnpackEdge(facade,
packed_v_t_path[via_path_index - 1],
packed_v_t_path[via_path_index],
partially_unpacked_via_path);
super::UnpackEdge(packed_shortest_path[shortest_path_index - 1],
super::UnpackEdge(facade,
packed_shortest_path[shortest_path_index - 1],
packed_shortest_path[shortest_path_index],
partially_unpacked_shortest_path);
break;
@@ -556,10 +570,10 @@ class AlternativeRouting final
partially_unpacked_via_path[via_path_index] ==
partially_unpacked_shortest_path[shortest_path_index])
{
EdgeID edgeID = facade->FindEdgeInEitherDirection(
EdgeID edgeID = facade.FindEdgeInEitherDirection(
partially_unpacked_via_path[via_path_index - 1],
partially_unpacked_via_path[via_path_index]);
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
*sharing_of_via_path += facade.GetEdgeData(edgeID).distance;
}
else
{
@@ -617,7 +631,8 @@ class AlternativeRouting final
// todo: reorder parameters
template <bool is_forward_directed>
void AlternativeRoutingStep(QueryHeap &heap1,
void AlternativeRoutingStep(const DataFacadeT &facade,
QueryHeap &heap1,
QueryHeap &heap2,
NodeID *middle_node,
int *upper_bound_to_shortest_path_distance,
@@ -667,7 +682,7 @@ class AlternativeRouting final
else
{
// check whether there is a loop present at the node
const auto loop_distance = super::GetLoopWeight(node);
const auto loop_distance = super::GetLoopWeight(facade, node);
const int new_distance_with_loop = new_distance + loop_distance;
if (loop_distance != INVALID_EDGE_WEIGHT &&
new_distance_with_loop <= *upper_bound_to_shortest_path_distance)
@@ -679,15 +694,15 @@ class AlternativeRouting final
}
}
for (auto edge : facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade->GetEdgeData(edge);
const EdgeData &data = facade.GetEdgeData(edge);
const bool edge_is_forward_directed =
(is_forward_directed ? data.forward : data.backward);
if (edge_is_forward_directed)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const int edge_weight = data.distance;
BOOST_ASSERT(edge_weight > 0);
@@ -711,7 +726,8 @@ class AlternativeRouting final
}
// conduct T-Test
bool ViaNodeCandidatePassesTTest(QueryHeap &existing_forward_heap,
bool ViaNodeCandidatePassesTTest(const DataFacadeT &facade,
QueryHeap &existing_forward_heap,
QueryHeap &existing_reverse_heap,
QueryHeap &new_forward_heap,
QueryHeap &new_reverse_heap,
@@ -735,7 +751,8 @@ class AlternativeRouting final
const bool constexpr DO_NOT_FORCE_LOOPS = false;
while (new_reverse_heap.Size() > 0)
{
super::RoutingStep(new_reverse_heap,
super::RoutingStep(facade,
new_reverse_heap,
existing_forward_heap,
*s_v_middle,
upper_bound_s_v_path_length,
@@ -757,7 +774,8 @@ class AlternativeRouting final
new_forward_heap.Insert(candidate.node, 0, candidate.node);
while (new_forward_heap.Size() > 0)
{
super::RoutingStep(new_forward_heap,
super::RoutingStep(facade,
new_forward_heap,
existing_reverse_heap,
*v_t_middle,
upper_bound_of_v_t_path_length,
@@ -800,8 +818,8 @@ class AlternativeRouting final
for (std::size_t i = packed_s_v_path.size() - 1; (i > 0) && unpack_stack.empty(); --i)
{
const EdgeID current_edge_id =
facade->FindEdgeInEitherDirection(packed_s_v_path[i - 1], packed_s_v_path[i]);
const int length_of_current_edge = facade->GetEdgeData(current_edge_id).distance;
facade.FindEdgeInEitherDirection(packed_s_v_path[i - 1], packed_s_v_path[i]);
const int length_of_current_edge = facade.GetEdgeData(current_edge_id).distance;
if ((length_of_current_edge + unpacked_until_distance) >= T_threshold)
{
unpack_stack.emplace(packed_s_v_path[i - 1], packed_s_v_path[i]);
@@ -818,22 +836,22 @@ class AlternativeRouting final
const SearchSpaceEdge via_path_edge = unpack_stack.top();
unpack_stack.pop();
EdgeID edge_in_via_path_id =
facade->FindEdgeInEitherDirection(via_path_edge.first, via_path_edge.second);
facade.FindEdgeInEitherDirection(via_path_edge.first, via_path_edge.second);
if (SPECIAL_EDGEID == edge_in_via_path_id)
{
return false;
}
const EdgeData &current_edge_data = facade->GetEdgeData(edge_in_via_path_id);
const EdgeData &current_edge_data = facade.GetEdgeData(edge_in_via_path_id);
const bool current_edge_is_shortcut = current_edge_data.shortcut;
if (current_edge_is_shortcut)
{
const NodeID via_path_middle_node_id = current_edge_data.id;
const EdgeID second_segment_edge_id = facade->FindEdgeInEitherDirection(
const EdgeID second_segment_edge_id = facade.FindEdgeInEitherDirection(
via_path_middle_node_id, via_path_edge.second);
const int second_segment_length =
facade->GetEdgeData(second_segment_edge_id).distance;
facade.GetEdgeData(second_segment_edge_id).distance;
// attention: !unpacking in reverse!
// Check if second segment is the one to go over treshold? if yes add second segment
// to stack, else push first segment to stack and add distance of second one.
@@ -864,8 +882,8 @@ class AlternativeRouting final
++i)
{
const EdgeID edgeID =
facade->FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]);
int length_of_current_edge = facade->GetEdgeData(edgeID).distance;
facade.FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]);
int length_of_current_edge = facade.GetEdgeData(edgeID).distance;
if (length_of_current_edge + unpacked_until_distance >= T_threshold)
{
unpack_stack.emplace(packed_v_t_path[i], packed_v_t_path[i + 1]);
@@ -882,20 +900,20 @@ class AlternativeRouting final
const SearchSpaceEdge via_path_edge = unpack_stack.top();
unpack_stack.pop();
EdgeID edge_in_via_path_id =
facade->FindEdgeInEitherDirection(via_path_edge.first, via_path_edge.second);
facade.FindEdgeInEitherDirection(via_path_edge.first, via_path_edge.second);
if (SPECIAL_EDGEID == edge_in_via_path_id)
{
return false;
}
const EdgeData &current_edge_data = facade->GetEdgeData(edge_in_via_path_id);
const EdgeData &current_edge_data = facade.GetEdgeData(edge_in_via_path_id);
const bool IsViaEdgeShortCut = current_edge_data.shortcut;
if (IsViaEdgeShortCut)
{
const NodeID middleOfViaPath = current_edge_data.id;
EdgeID edgeIDOfFirstSegment =
facade->FindEdgeInEitherDirection(via_path_edge.first, middleOfViaPath);
int lengthOfFirstSegment = facade->GetEdgeData(edgeIDOfFirstSegment).distance;
facade.FindEdgeInEitherDirection(via_path_edge.first, middleOfViaPath);
int lengthOfFirstSegment = facade.GetEdgeData(edgeIDOfFirstSegment).distance;
// Check if first segment is the one to go over treshold? if yes first segment to
// stack, else push second segment to stack and add distance of first one.
if (unpacked_until_distance + lengthOfFirstSegment >= T_threshold)
@@ -919,7 +937,7 @@ class AlternativeRouting final
t_test_path_length += unpacked_until_distance;
// Run actual T-Test query and compare if distances equal.
engine_working_data.InitializeOrClearThirdThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &forward_heap3 = *engine_working_data.forward_heap_3;
QueryHeap &reverse_heap3 = *engine_working_data.reverse_heap_3;
@@ -933,7 +951,8 @@ class AlternativeRouting final
{
if (!forward_heap3.Empty())
{
super::RoutingStep(forward_heap3,
super::RoutingStep(facade,
forward_heap3,
reverse_heap3,
middle,
upper_bound,
@@ -945,7 +964,8 @@ class AlternativeRouting final
}
if (!reverse_heap3.Empty())
{
super::RoutingStep(reverse_heap3,
super::RoutingStep(facade,
reverse_heap3,
forward_heap3,
middle,
upper_bound,
@@ -32,14 +32,15 @@ class DirectShortestPathRouting final
SearchEngineData &engine_working_data;
public:
DirectShortestPathRouting(DataFacadeT *facade, SearchEngineData &engine_working_data)
: super(facade), engine_working_data(engine_working_data)
DirectShortestPathRouting(SearchEngineData &engine_working_data)
: engine_working_data(engine_working_data)
{
}
~DirectShortestPathRouting() {}
void operator()(const std::vector<PhantomNodes> &phantom_nodes_vector,
void operator()(const DataFacadeT& facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
InternalRouteResult &raw_route_data) const
{
// Get distance to next pair of target nodes.
@@ -51,7 +52,7 @@ class DirectShortestPathRouting final
const auto &target_phantom = phantom_node_pair.target_phantom;
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
forward_heap.Clear();
@@ -93,16 +94,17 @@ class DirectShortestPathRouting final
const bool constexpr DO_NOT_FORCE_LOOPS =
false; // prevents forcing of loops, since offsets are set correctly
if (super::facade->GetCoreSize() > 0)
if (facade.GetCoreSize() > 0)
{
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &forward_core_heap = *(engine_working_data.forward_heap_2);
QueryHeap &reverse_core_heap = *(engine_working_data.reverse_heap_2);
forward_core_heap.Clear();
reverse_core_heap.Clear();
super::SearchWithCore(forward_heap,
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -113,7 +115,8 @@ class DirectShortestPathRouting final
}
else
{
super::Search(forward_heap,
super::Search(facade,
forward_heap,
reverse_heap,
distance,
packed_leg,
@@ -138,7 +141,8 @@ class DirectShortestPathRouting final
raw_route_data.target_traversed_in_reverse.push_back(
(packed_leg.back() != phantom_node_pair.target_phantom.forward_segment_id.id));
super::UnpackPath(packed_leg.begin(),
super::UnpackPath(facade,
packed_leg.begin(),
packed_leg.end(),
phantom_node_pair,
raw_route_data.unpacked_path_segments.front());
@@ -41,12 +41,13 @@ class ManyToManyRouting final
using SearchSpaceWithBuckets = std::unordered_map<NodeID, std::vector<NodeBucket>>;
public:
ManyToManyRouting(DataFacadeT *facade, SearchEngineData &engine_working_data)
: super(facade), engine_working_data(engine_working_data)
ManyToManyRouting(SearchEngineData &engine_working_data)
: engine_working_data(engine_working_data)
{
}
std::vector<EdgeWeight> operator()(const std::vector<PhantomNode> &phantom_nodes,
std::vector<EdgeWeight> operator()(const DataFacadeT& facade,
const std::vector<PhantomNode> &phantom_nodes,
const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices) const
{
@@ -59,7 +60,7 @@ class ManyToManyRouting final
std::numeric_limits<EdgeWeight>::max());
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &query_heap = *(engine_working_data.forward_heap_1);
@@ -86,7 +87,7 @@ class ManyToManyRouting final
// explore search space
while (!query_heap.Empty())
{
BackwardRoutingStep(column_idx, query_heap, search_space_with_buckets);
BackwardRoutingStep(facade, column_idx, query_heap, search_space_with_buckets);
}
++column_idx;
};
@@ -113,7 +114,8 @@ class ManyToManyRouting final
// explore search space
while (!query_heap.Empty())
{
ForwardRoutingStep(row_idx,
ForwardRoutingStep(facade,
row_idx,
number_of_targets,
query_heap,
search_space_with_buckets,
@@ -157,7 +159,8 @@ class ManyToManyRouting final
return result_table;
}
void ForwardRoutingStep(const unsigned row_idx,
void ForwardRoutingStep(const DataFacadeT &facade,
const unsigned row_idx,
const unsigned number_of_targets,
QueryHeap &query_heap,
const SearchSpaceWithBuckets &search_space_with_buckets,
@@ -182,7 +185,7 @@ class ManyToManyRouting final
const EdgeWeight new_distance = source_distance + target_distance;
if (new_distance < 0)
{
const EdgeWeight loop_weight = super::GetLoopWeight(node);
const EdgeWeight loop_weight = super::GetLoopWeight(facade, node);
const int new_distance_with_loop = new_distance + loop_weight;
if (loop_weight != INVALID_EDGE_WEIGHT && new_distance_with_loop >= 0)
{
@@ -195,14 +198,15 @@ class ManyToManyRouting final
}
}
}
if (StallAtNode<true>(node, source_distance, query_heap))
if (StallAtNode<true>(facade, node, source_distance, query_heap))
{
return;
}
RelaxOutgoingEdges<true>(node, source_distance, query_heap);
RelaxOutgoingEdges<true>(facade, node, source_distance, query_heap);
}
void BackwardRoutingStep(const unsigned column_idx,
void BackwardRoutingStep(const DataFacadeT &facade,
const unsigned column_idx,
QueryHeap &query_heap,
SearchSpaceWithBuckets &search_space_with_buckets) const
{
@@ -212,25 +216,27 @@ class ManyToManyRouting final
// store settled nodes in search space bucket
search_space_with_buckets[node].emplace_back(column_idx, target_distance);
if (StallAtNode<false>(node, target_distance, query_heap))
if (StallAtNode<false>(facade, node, target_distance, query_heap))
{
return;
}
RelaxOutgoingEdges<false>(node, target_distance, query_heap);
RelaxOutgoingEdges<false>(facade, node, target_distance, query_heap);
}
template <bool forward_direction>
inline void
RelaxOutgoingEdges(const NodeID node, const EdgeWeight distance, QueryHeap &query_heap) const
inline void RelaxOutgoingEdges(const DataFacadeT &facade,
const NodeID node,
const EdgeWeight distance,
QueryHeap &query_heap) const
{
for (auto edge : super::facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = super::facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
const bool direction_flag = (forward_direction ? data.forward : data.backward);
if (direction_flag)
{
const NodeID to = super::facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const int edge_weight = data.distance;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
@@ -254,16 +260,18 @@ class ManyToManyRouting final
// Stalling
template <bool forward_direction>
inline bool
StallAtNode(const NodeID node, const EdgeWeight distance, QueryHeap &query_heap) const
inline bool StallAtNode(const DataFacadeT &facade,
const NodeID node,
const EdgeWeight distance,
QueryHeap &query_heap) const
{
for (auto edge : super::facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = super::facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
const bool reverse_flag = ((!forward_direction) ? data.forward : data.backward);
if (reverse_flag)
{
const NodeID to = super::facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const int edge_weight = data.distance;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
if (query_heap.WasInserted(to))
@@ -63,17 +63,17 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
}
public:
MapMatching(DataFacadeT *facade,
SearchEngineData &engine_working_data,
MapMatching(SearchEngineData &engine_working_data,
const double default_gps_precision)
: super(facade), engine_working_data(engine_working_data),
: engine_working_data(engine_working_data),
default_emission_log_probability(default_gps_precision),
transition_log_probability(MATCHING_BETA)
{
}
SubMatchingList
operator()(const CandidateLists &candidates_list,
operator()(const DataFacadeT &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
@@ -159,9 +159,9 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
}
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
@@ -261,11 +261,12 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
reverse_heap.Clear();
double network_distance;
if (super::facade->GetCoreSize() > 0)
if (facade.GetCoreSize() > 0)
{
forward_core_heap.Clear();
reverse_core_heap.Clear();
network_distance = super::GetNetworkDistanceWithCore(
facade,
forward_heap,
reverse_heap,
forward_core_heap,
@@ -277,6 +278,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
else
{
network_distance = super::GetNetworkDistance(
facade,
forward_heap,
reverse_heap,
prev_unbroken_timestamps_list[s].phantom_node,
@@ -2,9 +2,9 @@
#define ROUTING_BASE_HPP
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/edge_unpacker.hpp"
#include "engine/internal_route_result.hpp"
#include "engine/search_engine_data.hpp"
#include "engine/edge_unpacker.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/typedefs.hpp"
@@ -33,16 +33,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
private:
using EdgeData = typename DataFacadeT::EdgeData;
protected:
DataFacadeT *facade;
public:
explicit BasicRoutingInterface(DataFacadeT *facade) : facade(facade) {}
~BasicRoutingInterface() {}
BasicRoutingInterface(const BasicRoutingInterface &) = delete;
BasicRoutingInterface &operator=(const BasicRoutingInterface &) = delete;
/*
min_edge_offset is needed in case we use multiple
nodes as start/target nodes with different (even negative) offsets.
@@ -72,7 +63,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
Since we are dealing with a graph that contains _negative_ edges,
we need to add an offset to the termination criterion.
*/
void RoutingStep(SearchEngineData::QueryHeap &forward_heap,
void RoutingStep(const DataFacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
NodeID &middle_node_id,
std::int32_t &upper_bound,
@@ -98,14 +90,14 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
new_distance < 0)
{
// check whether there is a loop present at the node
for (const auto edge : facade->GetAdjacentEdgeRange(node))
for (const auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade->GetEdgeData(edge);
const EdgeData &data = facade.GetEdgeData(edge);
bool forward_directionFlag =
(forward_direction ? data.forward : data.backward);
if (forward_directionFlag)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
if (to == node)
{
const EdgeWeight edge_weight = data.distance;
@@ -141,13 +133,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
// Stalling
if (stalling)
{
for (const auto edge : facade->GetAdjacentEdgeRange(node))
for (const auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade->GetEdgeData(edge);
const EdgeData &data = facade.GetEdgeData(edge);
const bool reverse_flag = ((!forward_direction) ? data.forward : data.backward);
if (reverse_flag)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.distance;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
@@ -163,14 +155,14 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
}
for (const auto edge : facade->GetAdjacentEdgeRange(node))
for (const auto edge : facade.GetAdjacentEdgeRange(node))
{
const EdgeData &data = facade->GetEdgeData(edge);
const EdgeData &data = facade.GetEdgeData(edge);
bool forward_directionFlag = (forward_direction ? data.forward : data.backward);
if (forward_directionFlag)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
const EdgeWeight edge_weight = data.distance;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
@@ -192,15 +184,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
}
inline EdgeWeight GetLoopWeight(NodeID node) const
inline EdgeWeight GetLoopWeight(const DataFacadeT &facade, NodeID node) const
{
EdgeWeight loop_weight = INVALID_EDGE_WEIGHT;
for (auto edge : facade->GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade->GetEdgeData(edge);
const auto &data = facade.GetEdgeData(edge);
if (data.forward)
{
const NodeID to = facade->GetTarget(edge);
const NodeID to = facade.GetTarget(edge);
if (to == node)
{
loop_weight = std::min(loop_weight, data.distance);
@@ -211,7 +203,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
template <typename RandomIter>
void UnpackPath(RandomIter packed_path_begin,
void UnpackPath(const DataFacadeT &facade,
RandomIter packed_path_begin,
RandomIter packed_path_end,
const PhantomNodes &phantom_node_pair,
std::vector<PathData> &unpacked_path) const
@@ -230,10 +223,11 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id);
UnpackCHPath(
*facade,
facade,
packed_path_begin,
packed_path_end,
[this,
&facade,
&unpacked_path,
&phantom_node_pair,
&start_traversed_in_reverse,
@@ -241,26 +235,27 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
const EdgeData &edge_data) {
BOOST_ASSERT_MSG(!edge_data.shortcut, "original edge flagged as shortcut");
const auto name_index = facade->GetNameIndexFromEdgeID(edge_data.id);
const auto turn_instruction = facade->GetTurnInstructionForEdgeID(edge_data.id);
const auto name_index = facade.GetNameIndexFromEdgeID(edge_data.id);
const auto turn_instruction = facade.GetTurnInstructionForEdgeID(edge_data.id);
const extractor::TravelMode travel_mode =
(unpacked_path.empty() && start_traversed_in_reverse)
? phantom_node_pair.source_phantom.backward_travel_mode
: facade->GetTravelModeForEdgeID(edge_data.id);
: facade.GetTravelModeForEdgeID(edge_data.id);
const auto geometry_index = facade->GetGeometryIndexForEdgeID(edge_data.id);
const auto geometry_index = facade.GetGeometryIndexForEdgeID(edge_data.id);
std::vector<NodeID> id_vector;
facade->GetUncompressedGeometry(geometry_index, id_vector);
facade.GetUncompressedGeometry(geometry_index, id_vector);
BOOST_ASSERT(id_vector.size() > 0);
std::vector<EdgeWeight> weight_vector;
facade->GetUncompressedWeights(geometry_index, weight_vector);
facade.GetUncompressedWeights(geometry_index, weight_vector);
BOOST_ASSERT(weight_vector.size() > 0);
std::vector<DatasourceID> datasource_vector;
facade->GetUncompressedDatasources(geometry_index, datasource_vector);
facade.GetUncompressedDatasources(geometry_index, datasource_vector);
const auto total_weight = std::accumulate(weight_vector.begin(), weight_vector.end(), 0);
const auto total_weight =
std::accumulate(weight_vector.begin(), weight_vector.end(), 0);
BOOST_ASSERT(weight_vector.size() == id_vector.size());
const bool is_first_segment = unpacked_path.empty();
@@ -289,10 +284,10 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
datasource_vector[i]});
}
BOOST_ASSERT(unpacked_path.size() > 0);
if (facade->hasLaneData(edge_data.id))
unpacked_path.back().lane_data = facade->GetLaneData(edge_data.id);
if (facade.hasLaneData(edge_data.id))
unpacked_path.back().lane_data = facade.GetLaneData(edge_data.id);
unpacked_path.back().entry_classid = facade->GetEntryClassID(edge_data.id);
unpacked_path.back().entry_classid = facade.GetEntryClassID(edge_data.id);
unpacked_path.back().turn_instruction = turn_instruction;
unpacked_path.back().duration_until_turn += (edge_data.distance - total_weight);
});
@@ -307,13 +302,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
if (target_traversed_in_reverse)
{
facade->GetUncompressedGeometry(
facade.GetUncompressedGeometry(
phantom_node_pair.target_phantom.reverse_packed_geometry_id, id_vector);
facade->GetUncompressedWeights(
facade.GetUncompressedWeights(
phantom_node_pair.target_phantom.reverse_packed_geometry_id, weight_vector);
facade->GetUncompressedDatasources(
facade.GetUncompressedDatasources(
phantom_node_pair.target_phantom.reverse_packed_geometry_id, datasource_vector);
if (is_local_path)
@@ -331,13 +326,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
start_index = phantom_node_pair.source_phantom.fwd_segment_position;
}
end_index = phantom_node_pair.target_phantom.fwd_segment_position;
facade->GetUncompressedGeometry(
facade.GetUncompressedGeometry(
phantom_node_pair.target_phantom.forward_packed_geometry_id, id_vector);
facade->GetUncompressedWeights(
facade.GetUncompressedWeights(
phantom_node_pair.target_phantom.forward_packed_geometry_id, weight_vector);
facade->GetUncompressedDatasources(
facade.GetUncompressedDatasources(
phantom_node_pair.target_phantom.forward_packed_geometry_id, datasource_vector);
}
@@ -412,11 +407,14 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
* @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 UnpackEdge(const NodeID from, const NodeID to, std::vector<NodeID> &unpacked_path) const
void UnpackEdge(const DataFacadeT &facade,
const NodeID from,
const NodeID to,
std::vector<NodeID> &unpacked_path) const
{
std::array<NodeID, 2> path{{from, to}};
UnpackCHPath(
*facade,
facade,
path.begin(),
path.end(),
[&unpacked_path](const std::pair<NodeID, NodeID> &edge, const EdgeData & /* data */) {
@@ -465,7 +463,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void Search(SearchEngineData::QueryHeap &forward_heap,
void Search(const DataFacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
std::int32_t &distance,
std::vector<NodeID> &packed_leg,
@@ -488,7 +487,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
{
if (!forward_heap.Empty())
{
RoutingStep(forward_heap,
RoutingStep(facade,
forward_heap,
reverse_heap,
middle,
distance,
@@ -500,7 +500,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
if (!reverse_heap.Empty())
{
RoutingStep(reverse_heap,
RoutingStep(facade,
reverse_heap,
forward_heap,
middle,
distance,
@@ -545,7 +546,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
// requires
// a force loop, if the heaps have been initialized with positive offsets.
void SearchWithCore(SearchEngineData::QueryHeap &forward_heap,
void SearchWithCore(const DataFacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
@@ -573,7 +575,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
{
if (!forward_heap.Empty())
{
if (facade->IsCoreNode(forward_heap.Min()))
if (facade.IsCoreNode(forward_heap.Min()))
{
const NodeID node = forward_heap.DeleteMin();
const int key = forward_heap.GetKey(node);
@@ -581,7 +583,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
else
{
RoutingStep(forward_heap,
RoutingStep(facade,
forward_heap,
reverse_heap,
middle,
distance,
@@ -594,7 +597,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
if (!reverse_heap.Empty())
{
if (facade->IsCoreNode(reverse_heap.Min()))
if (facade.IsCoreNode(reverse_heap.Min()))
{
const NodeID node = reverse_heap.DeleteMin();
const int key = reverse_heap.GetKey(node);
@@ -602,7 +605,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
else
{
RoutingStep(reverse_heap,
RoutingStep(facade,
reverse_heap,
forward_heap,
middle,
distance,
@@ -654,7 +658,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() &&
distance > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
{
RoutingStep(forward_core_heap,
RoutingStep(facade,
forward_core_heap,
reverse_core_heap,
middle,
distance,
@@ -664,7 +669,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
force_loop_forward,
force_loop_reverse);
RoutingStep(reverse_core_heap,
RoutingStep(facade,
reverse_core_heap,
forward_core_heap,
middle,
distance,
@@ -687,7 +693,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
"no path found");
// we need to unpack sub path from core heaps
if (facade->IsCoreNode(middle))
if (facade.IsCoreNode(middle))
{
if (distance != forward_core_heap.GetKey(middle) + reverse_core_heap.GetKey(middle))
{
@@ -746,7 +752,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
target_phantom.GetReverseWeightPlusOffset();
}
double GetPathDistance(const std::vector<NodeID> &packed_path,
double GetPathDistance(const DataFacadeT &facade,
const std::vector<NodeID> &packed_path,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom) const
{
@@ -754,7 +761,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
PhantomNodes nodes;
nodes.source_phantom = source_phantom;
nodes.target_phantom = target_phantom;
UnpackPath(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;
@@ -767,7 +774,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
double prev_cos = std::cos(prev_lat);
for (const auto &p : unpacked_path)
{
const auto current_coordinate = facade->GetCoordinateOfNode(p.turn_via_node);
const auto current_coordinate = facade.GetCoordinateOfNode(p.turn_via_node);
const double current_lat =
static_cast<double>(toFloating(current_coordinate.lat)) * DEGREE_TO_RAD;
@@ -806,7 +813,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
// 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 GetNetworkDistanceWithCore(SearchEngineData::QueryHeap &forward_heap,
double GetNetworkDistanceWithCore(const DataFacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
SearchEngineData::QueryHeap &forward_core_heap,
SearchEngineData::QueryHeap &reverse_core_heap,
@@ -848,7 +856,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
int duration = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_path;
SearchWithCore(forward_heap,
SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -861,7 +870,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
double distance = std::numeric_limits<double>::max();
if (duration != INVALID_EDGE_WEIGHT)
{
return GetPathDistance(packed_path, source_phantom, target_phantom);
return GetPathDistance(facade, packed_path, source_phantom, target_phantom);
}
return distance;
}
@@ -869,7 +878,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
// 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 GetNetworkDistance(SearchEngineData::QueryHeap &forward_heap,
double GetNetworkDistance(const DataFacadeT &facade,
SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
@@ -909,7 +919,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
int duration = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_path;
Search(forward_heap,
Search(facade,
forward_heap,
reverse_heap,
duration,
packed_path,
@@ -922,7 +933,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
return std::numeric_limits<double>::max();
}
return GetPathDistance(packed_path, source_phantom, target_phantom);
return GetPathDistance(facade, packed_path, source_phantom, target_phantom);
}
};
}
@@ -28,8 +28,8 @@ class ShortestPathRouting final
const static constexpr bool DO_NOT_FORCE_LOOP = false;
public:
ShortestPathRouting(DataFacadeT *facade, SearchEngineData &engine_working_data)
: super(facade), engine_working_data(engine_working_data)
ShortestPathRouting(SearchEngineData &engine_working_data)
: engine_working_data(engine_working_data)
{
}
@@ -37,7 +37,8 @@ class ShortestPathRouting final
// allows a uturn at the target_phantom
// searches source forward/reverse -> target forward/reverse
void SearchWithUTurn(QueryHeap &forward_heap,
void SearchWithUTurn(const DataFacadeT &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
QueryHeap &reverse_core_heap,
@@ -90,13 +91,14 @@ class ShortestPathRouting final
is_oneway_source && super::NeedsLoopForward(source_phantom, target_phantom);
auto needs_loop_backwards =
is_oneway_target && super::NeedsLoopBackwards(source_phantom, target_phantom);
if (super::facade->GetCoreSize() > 0)
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(forward_heap,
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -107,7 +109,8 @@ class ShortestPathRouting final
}
else
{
super::Search(forward_heap,
super::Search(facade,
forward_heap,
reverse_heap,
new_total_distance,
leg_packed_path,
@@ -124,7 +127,8 @@ class ShortestPathRouting final
// searches shortest path between:
// source forward/reverse -> target forward
// source forward/reverse -> target reverse
void Search(QueryHeap &forward_heap,
void Search(const DataFacadeT &facade,
QueryHeap &forward_heap,
QueryHeap &reverse_heap,
QueryHeap &forward_core_heap,
QueryHeap &reverse_core_heap,
@@ -166,13 +170,14 @@ class ShortestPathRouting final
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
if (super::facade->GetCoreSize() > 0)
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(forward_heap,
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -183,7 +188,8 @@ class ShortestPathRouting final
}
else
{
super::Search(forward_heap,
super::Search(facade,
forward_heap,
reverse_heap,
new_total_distance_to_forward,
leg_packed_path_forward,
@@ -215,13 +221,14 @@ class ShortestPathRouting final
}
BOOST_ASSERT(forward_heap.Size() > 0);
BOOST_ASSERT(reverse_heap.Size() > 0);
if (super::facade->GetCoreSize() > 0)
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(forward_heap,
super::SearchWithCore(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -232,7 +239,8 @@ class ShortestPathRouting final
}
else
{
super::Search(forward_heap,
super::Search(facade,
forward_heap,
reverse_heap,
new_total_distance_to_reverse,
leg_packed_path_reverse,
@@ -242,7 +250,8 @@ class ShortestPathRouting final
}
}
void UnpackLegs(const std::vector<PhantomNodes> &phantom_nodes_vector,
void UnpackLegs(const DataFacadeT &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,
@@ -257,7 +266,8 @@ class ShortestPathRouting final
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(leg_begin,
super::UnpackPath(facade,
leg_begin,
leg_end,
unpack_phantom_node_pair,
raw_route_data.unpacked_path_segments[current_leg]);
@@ -271,18 +281,19 @@ class ShortestPathRouting final
}
}
void operator()(const std::vector<PhantomNodes> &phantom_nodes_vector,
void operator()(const DataFacadeT &facade,
const std::vector<PhantomNodes> &phantom_nodes_vector,
const boost::optional<bool> continue_straight_at_waypoint,
InternalRouteResult &raw_route_data) const
{
const bool allow_uturn_at_waypoint =
!(continue_straight_at_waypoint ? *continue_straight_at_waypoint
: super::facade->GetContinueStraightDefault());
: facade.GetContinueStraightDefault());
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
super::facade->GetNumberOfNodes());
facade.GetNumberOfNodes());
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
@@ -330,7 +341,8 @@ class ShortestPathRouting final
{
if (allow_uturn_at_waypoint)
{
SearchWithUTurn(forward_heap,
SearchWithUTurn(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -361,7 +373,8 @@ class ShortestPathRouting final
}
else
{
Search(forward_heap,
Search(facade,
forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
@@ -489,7 +502,8 @@ class ShortestPathRouting final
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(phantom_nodes_vector,
UnpackLegs(facade,
phantom_nodes_vector,
total_packed_path_to_reverse,
packed_leg_to_reverse_begin,
total_distance_to_reverse,
@@ -501,7 +515,8 @@ class ShortestPathRouting final
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(phantom_nodes_vector,
UnpackLegs(facade,
phantom_nodes_vector,
total_packed_path_to_forward,
packed_leg_to_forward_begin,
total_distance_to_forward,