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:
parent
66f2cc5184
commit
1c2ead8fb8
@ -80,7 +80,7 @@ class Engine final
|
||||
std::unique_ptr<plugins::MatchPlugin> match_plugin;
|
||||
std::unique_ptr<plugins::TilePlugin> tile_plugin;
|
||||
|
||||
std::unique_ptr<datafacade::BaseDataFacade> query_data_facade;
|
||||
std::shared_ptr<datafacade::BaseDataFacade> query_data_facade;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,15 @@ class MatchPlugin : public BasePlugin
|
||||
static const constexpr double DEFAULT_GPS_PRECISION = 5;
|
||||
static const constexpr double RADIUS_MULTIPLIER = 3;
|
||||
|
||||
MatchPlugin(datafacade::BaseDataFacade &facade_, const int max_locations_map_matching)
|
||||
: BasePlugin(facade_), map_matching(&facade_, heaps, DEFAULT_GPS_PRECISION),
|
||||
shortest_path(&facade_, heaps), max_locations_map_matching(max_locations_map_matching)
|
||||
MatchPlugin(const int max_locations_map_matching)
|
||||
: map_matching(heaps, DEFAULT_GPS_PRECISION),
|
||||
shortest_path(heaps), max_locations_map_matching(max_locations_map_matching)
|
||||
{
|
||||
}
|
||||
|
||||
Status HandleRequest(const api::MatchParameters ¶meters, util::json::Object &json_result);
|
||||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::MatchParameters ¶meters,
|
||||
util::json::Object &json_result);
|
||||
|
||||
private:
|
||||
SearchEngineData heaps;
|
||||
|
@ -15,9 +15,11 @@ namespace plugins
|
||||
class NearestPlugin final : public BasePlugin
|
||||
{
|
||||
public:
|
||||
explicit NearestPlugin(datafacade::BaseDataFacade &facade, const int max_results);
|
||||
explicit NearestPlugin(const int max_results);
|
||||
|
||||
Status HandleRequest(const api::NearestParameters ¶ms, util::json::Object &result);
|
||||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::NearestParameters ¶ms,
|
||||
util::json::Object &result) const;
|
||||
|
||||
private:
|
||||
const int max_results;
|
||||
|
@ -26,10 +26,7 @@ namespace plugins
|
||||
class BasePlugin
|
||||
{
|
||||
protected:
|
||||
datafacade::BaseDataFacade &facade;
|
||||
BasePlugin(datafacade::BaseDataFacade &facade_) : facade(facade_) {}
|
||||
|
||||
bool CheckAllCoordinates(const std::vector<util::Coordinate> &coordinates)
|
||||
bool CheckAllCoordinates(const std::vector<util::Coordinate> &coordinates) const
|
||||
{
|
||||
return !std::any_of(
|
||||
std::begin(coordinates), std::end(coordinates), [](const util::Coordinate coordinate) {
|
||||
@ -111,7 +108,8 @@ class BasePlugin
|
||||
|
||||
// Falls back to default_radius for non-set radii
|
||||
std::vector<std::vector<PhantomNodeWithDistance>>
|
||||
GetPhantomNodesInRange(const api::BaseParameters ¶meters,
|
||||
GetPhantomNodesInRange(const datafacade::BaseDataFacade &facade,
|
||||
const api::BaseParameters ¶meters,
|
||||
const std::vector<double> radiuses) const
|
||||
{
|
||||
std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes(
|
||||
@ -152,7 +150,9 @@ class BasePlugin
|
||||
}
|
||||
|
||||
std::vector<std::vector<PhantomNodeWithDistance>>
|
||||
GetPhantomNodes(const api::BaseParameters ¶meters, unsigned number_of_results)
|
||||
GetPhantomNodes(const datafacade::BaseDataFacade &facade,
|
||||
const api::BaseParameters ¶meters,
|
||||
unsigned number_of_results) const
|
||||
{
|
||||
std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes(
|
||||
parameters.coordinates.size());
|
||||
@ -216,7 +216,8 @@ class BasePlugin
|
||||
return phantom_nodes;
|
||||
}
|
||||
|
||||
std::vector<PhantomNodePair> GetPhantomNodes(const api::BaseParameters ¶meters)
|
||||
std::vector<PhantomNodePair> GetPhantomNodes(const datafacade::BaseDataFacade &facade,
|
||||
const api::BaseParameters ¶meters) const
|
||||
{
|
||||
std::vector<PhantomNodePair> phantom_node_pairs(parameters.coordinates.size());
|
||||
|
||||
|
@ -18,10 +18,11 @@ namespace plugins
|
||||
class TablePlugin final : public BasePlugin
|
||||
{
|
||||
public:
|
||||
explicit TablePlugin(datafacade::BaseDataFacade &facade,
|
||||
const int max_locations_distance_table);
|
||||
explicit TablePlugin(const int max_locations_distance_table);
|
||||
|
||||
Status HandleRequest(const api::TableParameters ¶ms, util::json::Object &result);
|
||||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::TableParameters ¶ms,
|
||||
util::json::Object &result);
|
||||
|
||||
private:
|
||||
SearchEngineData heaps;
|
||||
|
@ -26,9 +26,7 @@ namespace plugins
|
||||
class TilePlugin final : public BasePlugin
|
||||
{
|
||||
public:
|
||||
TilePlugin(datafacade::BaseDataFacade &facade) : BasePlugin(facade) {}
|
||||
|
||||
Status HandleRequest(const api::TileParameters ¶meters, std::string &pbf_buffer);
|
||||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade, const api::TileParameters ¶meters, std::string &pbf_buffer) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -34,17 +34,20 @@ class TripPlugin final : public BasePlugin
|
||||
routing_algorithms::ManyToManyRouting<datafacade::BaseDataFacade> duration_table;
|
||||
int max_locations_trip;
|
||||
|
||||
InternalRouteResult ComputeRoute(const std::vector<PhantomNode> &phantom_node_list,
|
||||
InternalRouteResult ComputeRoute(const datafacade::BaseDataFacade &facade,
|
||||
const std::vector<PhantomNode> &phantom_node_list,
|
||||
const std::vector<NodeID> &trip);
|
||||
|
||||
public:
|
||||
explicit TripPlugin(datafacade::BaseDataFacade &facade_, const int max_locations_trip_)
|
||||
: BasePlugin(facade_), shortest_path(&facade_, heaps), duration_table(&facade_, heaps),
|
||||
explicit TripPlugin(const int max_locations_trip_)
|
||||
: shortest_path(heaps), duration_table(heaps),
|
||||
max_locations_trip(max_locations_trip_)
|
||||
{
|
||||
}
|
||||
|
||||
Status HandleRequest(const api::TripParameters ¶meters, util::json::Object &json_result);
|
||||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::TripParameters ¶meters,
|
||||
util::json::Object &json_result);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,10 @@ class ViaRoutePlugin final : public BasePlugin
|
||||
int max_locations_viaroute;
|
||||
|
||||
public:
|
||||
explicit ViaRoutePlugin(datafacade::BaseDataFacade &facade, int max_locations_viaroute);
|
||||
explicit ViaRoutePlugin(int max_locations_viaroute);
|
||||
|
||||
Status HandleRequest(const api::RouteParameters &route_parameters,
|
||||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::RouteParameters &route_parameters,
|
||||
util::json::Object &json_result);
|
||||
};
|
||||
}
|
||||
|
@ -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 ¤t_edge_data = facade->GetEdgeData(edge_in_via_path_id);
|
||||
const EdgeData ¤t_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 ¤t_edge_data = facade->GetEdgeData(edge_in_via_path_id);
|
||||
const EdgeData ¤t_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,
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "engine/datafacade/shared_datafacade.hpp"
|
||||
|
||||
#include "storage/shared_barriers.hpp"
|
||||
#include "util/make_unique.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
@ -86,37 +85,31 @@ namespace
|
||||
// Works the same for every plugin.
|
||||
template <typename ParameterT, typename PluginT, typename ResultT>
|
||||
osrm::engine::Status RunQuery(const std::unique_ptr<osrm::engine::Engine::EngineLock> &lock,
|
||||
osrm::engine::datafacade::BaseDataFacade &facade,
|
||||
const std::shared_ptr<osrm::engine::datafacade::BaseDataFacade> &facade,
|
||||
const ParameterT ¶meters,
|
||||
PluginT &plugin,
|
||||
ResultT &result)
|
||||
{
|
||||
if (!lock)
|
||||
{
|
||||
return plugin.HandleRequest(parameters, result);
|
||||
return plugin.HandleRequest(facade, parameters, result);
|
||||
}
|
||||
|
||||
BOOST_ASSERT(lock);
|
||||
lock->IncreaseQueryCount();
|
||||
|
||||
auto &shared_facade = static_cast<osrm::engine::datafacade::SharedDataFacade &>(facade);
|
||||
auto &shared_facade = static_cast<osrm::engine::datafacade::SharedDataFacade &>(*facade);
|
||||
shared_facade.CheckAndReloadFacade();
|
||||
// Get a shared data lock so that other threads won't update
|
||||
// things while the query is running
|
||||
boost::shared_lock<boost::shared_mutex> data_lock{shared_facade.data_mutex};
|
||||
|
||||
osrm::engine::Status status = plugin.HandleRequest(parameters, result);
|
||||
osrm::engine::Status status = plugin.HandleRequest(facade, parameters, result);
|
||||
|
||||
lock->DecreaseQueryCount();
|
||||
return status;
|
||||
}
|
||||
|
||||
template <typename Plugin, typename Facade, typename... Args>
|
||||
std::unique_ptr<Plugin> create(Facade &facade, Args... args)
|
||||
{
|
||||
return osrm::util::make_unique<Plugin>(facade, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
} // anon. ns
|
||||
|
||||
namespace osrm
|
||||
@ -128,8 +121,8 @@ Engine::Engine(const EngineConfig &config)
|
||||
{
|
||||
if (config.use_shared_memory)
|
||||
{
|
||||
lock = util::make_unique<EngineLock>();
|
||||
query_data_facade = util::make_unique<datafacade::SharedDataFacade>();
|
||||
lock = std::make_unique<EngineLock>();
|
||||
query_data_facade = std::make_shared<datafacade::SharedDataFacade>();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -138,18 +131,18 @@ Engine::Engine(const EngineConfig &config)
|
||||
throw util::exception("Invalid file paths given!");
|
||||
}
|
||||
query_data_facade =
|
||||
util::make_unique<datafacade::InternalDataFacade>(config.storage_config);
|
||||
std::make_shared<datafacade::InternalDataFacade>(config.storage_config);
|
||||
}
|
||||
|
||||
// Register plugins
|
||||
using namespace plugins;
|
||||
|
||||
route_plugin = create<ViaRoutePlugin>(*query_data_facade, config.max_locations_viaroute);
|
||||
table_plugin = create<TablePlugin>(*query_data_facade, config.max_locations_distance_table);
|
||||
nearest_plugin = create<NearestPlugin>(*query_data_facade, config.max_results_nearest);
|
||||
trip_plugin = create<TripPlugin>(*query_data_facade, config.max_locations_trip);
|
||||
match_plugin = create<MatchPlugin>(*query_data_facade, config.max_locations_map_matching);
|
||||
tile_plugin = create<TilePlugin>(*query_data_facade);
|
||||
route_plugin = std::make_unique<ViaRoutePlugin>(config.max_locations_viaroute);
|
||||
table_plugin = std::make_unique<TablePlugin>(config.max_locations_distance_table);
|
||||
nearest_plugin = std::make_unique<NearestPlugin>(config.max_results_nearest);
|
||||
trip_plugin = std::make_unique<TripPlugin>(config.max_locations_trip);
|
||||
match_plugin = std::make_unique<MatchPlugin>(config.max_locations_map_matching);
|
||||
tile_plugin = std::make_unique<TilePlugin>();
|
||||
}
|
||||
|
||||
// make sure we deallocate the unique ptr at a position where we know the size of the plugins
|
||||
@ -159,32 +152,32 @@ Engine &Engine::operator=(Engine &&) noexcept = default;
|
||||
|
||||
Status Engine::Route(const api::RouteParameters ¶ms, util::json::Object &result) const
|
||||
{
|
||||
return RunQuery(lock, *query_data_facade, params, *route_plugin, result);
|
||||
return RunQuery(lock, query_data_facade, params, *route_plugin, result);
|
||||
}
|
||||
|
||||
Status Engine::Table(const api::TableParameters ¶ms, util::json::Object &result) const
|
||||
{
|
||||
return RunQuery(lock, *query_data_facade, params, *table_plugin, result);
|
||||
return RunQuery(lock, query_data_facade, params, *table_plugin, result);
|
||||
}
|
||||
|
||||
Status Engine::Nearest(const api::NearestParameters ¶ms, util::json::Object &result) const
|
||||
{
|
||||
return RunQuery(lock, *query_data_facade, params, *nearest_plugin, result);
|
||||
return RunQuery(lock, query_data_facade, params, *nearest_plugin, result);
|
||||
}
|
||||
|
||||
Status Engine::Trip(const api::TripParameters ¶ms, util::json::Object &result) const
|
||||
{
|
||||
return RunQuery(lock, *query_data_facade, params, *trip_plugin, result);
|
||||
return RunQuery(lock, query_data_facade, params, *trip_plugin, result);
|
||||
}
|
||||
|
||||
Status Engine::Match(const api::MatchParameters ¶ms, util::json::Object &result) const
|
||||
{
|
||||
return RunQuery(lock, *query_data_facade, params, *match_plugin, result);
|
||||
return RunQuery(lock, query_data_facade, params, *match_plugin, result);
|
||||
}
|
||||
|
||||
Status Engine::Tile(const api::TileParameters ¶ms, std::string &result) const
|
||||
{
|
||||
return RunQuery(lock, *query_data_facade, params, *tile_plugin, result);
|
||||
return RunQuery(lock, query_data_facade, params, *tile_plugin, result);
|
||||
}
|
||||
|
||||
} // engine ns
|
||||
|
@ -105,7 +105,8 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
|
||||
}
|
||||
}
|
||||
|
||||
Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
Status MatchPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::MatchParameters ¶meters,
|
||||
util::json::Object &json_result)
|
||||
{
|
||||
BOOST_ASSERT(parameters.IsValid());
|
||||
@ -150,7 +151,7 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
});
|
||||
}
|
||||
|
||||
auto candidates_lists = GetPhantomNodesInRange(parameters, search_radiuses);
|
||||
auto candidates_lists = GetPhantomNodesInRange(*facade, parameters, search_radiuses);
|
||||
|
||||
filterCandidates(parameters.coordinates, candidates_lists);
|
||||
if (std::all_of(candidates_lists.begin(),
|
||||
@ -165,7 +166,7 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
}
|
||||
|
||||
// call the actual map matching
|
||||
SubMatchingList sub_matchings = map_matching(
|
||||
SubMatchingList sub_matchings = map_matching(*facade,
|
||||
candidates_lists, parameters.coordinates, parameters.timestamps, parameters.radiuses);
|
||||
|
||||
if (sub_matchings.size() == 0)
|
||||
@ -192,11 +193,11 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
// force uturns to be on, since we split the phantom nodes anyway and only have
|
||||
// bi-directional
|
||||
// phantom nodes for possible uturns
|
||||
shortest_path(sub_routes[index].segment_end_coordinates, {false}, sub_routes[index]);
|
||||
shortest_path(*facade, sub_routes[index].segment_end_coordinates, {false}, sub_routes[index]);
|
||||
BOOST_ASSERT(sub_routes[index].shortest_path_length != INVALID_EDGE_WEIGHT);
|
||||
}
|
||||
|
||||
api::MatchAPI match_api{BasePlugin::facade, parameters};
|
||||
api::MatchAPI match_api{*facade, parameters};
|
||||
match_api.MakeResponse(sub_matchings, sub_routes, json_result);
|
||||
|
||||
return Status::Ok;
|
||||
|
@ -17,13 +17,14 @@ namespace engine
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
NearestPlugin::NearestPlugin(datafacade::BaseDataFacade &facade, const int max_results_)
|
||||
: BasePlugin{facade}, max_results{max_results_}
|
||||
NearestPlugin::NearestPlugin(const int max_results_)
|
||||
: max_results{max_results_}
|
||||
{
|
||||
}
|
||||
|
||||
Status NearestPlugin::HandleRequest(const api::NearestParameters ¶ms,
|
||||
util::json::Object &json_result)
|
||||
Status NearestPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::NearestParameters ¶ms,
|
||||
util::json::Object &json_result) const
|
||||
{
|
||||
BOOST_ASSERT(params.IsValid());
|
||||
|
||||
@ -44,7 +45,7 @@ Status NearestPlugin::HandleRequest(const api::NearestParameters ¶ms,
|
||||
return Error("InvalidOptions", "Only one input coordinate is supported", json_result);
|
||||
}
|
||||
|
||||
auto phantom_nodes = GetPhantomNodes(params, params.number_of_results);
|
||||
auto phantom_nodes = GetPhantomNodes(*facade, params, params.number_of_results);
|
||||
|
||||
if (phantom_nodes.front().size() == 0)
|
||||
{
|
||||
@ -52,7 +53,7 @@ Status NearestPlugin::HandleRequest(const api::NearestParameters ¶ms,
|
||||
}
|
||||
BOOST_ASSERT(phantom_nodes.front().size() > 0);
|
||||
|
||||
api::NearestAPI nearest_api(facade, params);
|
||||
api::NearestAPI nearest_api(*facade, params);
|
||||
nearest_api.MakeResponse(phantom_nodes, json_result);
|
||||
|
||||
return Status::Ok;
|
||||
|
@ -23,13 +23,15 @@ namespace engine
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
TablePlugin::TablePlugin(datafacade::BaseDataFacade &facade, const int max_locations_distance_table)
|
||||
: BasePlugin{facade}, distance_table(&facade, heaps),
|
||||
TablePlugin::TablePlugin(const int max_locations_distance_table)
|
||||
: distance_table(heaps),
|
||||
max_locations_distance_table(max_locations_distance_table)
|
||||
{
|
||||
}
|
||||
|
||||
Status TablePlugin::HandleRequest(const api::TableParameters ¶ms, util::json::Object &result)
|
||||
Status TablePlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::TableParameters ¶ms,
|
||||
util::json::Object &result)
|
||||
{
|
||||
BOOST_ASSERT(params.IsValid());
|
||||
|
||||
@ -58,15 +60,15 @@ Status TablePlugin::HandleRequest(const api::TableParameters ¶ms, util::json
|
||||
return Error("TooBig", "Too many table coordinates", result);
|
||||
}
|
||||
|
||||
auto snapped_phantoms = SnapPhantomNodes(GetPhantomNodes(params));
|
||||
auto result_table = distance_table(snapped_phantoms, params.sources, params.destinations);
|
||||
auto snapped_phantoms = SnapPhantomNodes(GetPhantomNodes(*facade, params));
|
||||
auto result_table = distance_table(*facade, snapped_phantoms, params.sources, params.destinations);
|
||||
|
||||
if (result_table.empty())
|
||||
{
|
||||
return Error("NoTable", "No table found", result);
|
||||
}
|
||||
|
||||
api::TableAPI table_api{facade, params};
|
||||
api::TableAPI table_api{*facade, params};
|
||||
table_api.MakeResponse(result_table, snapped_phantoms, result);
|
||||
|
||||
return Status::Ok;
|
||||
|
@ -269,7 +269,9 @@ void UnpackEdgeToEdges(const datafacade::BaseDataFacade &facade,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::string &pbf_buffer)
|
||||
Status TilePlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::TileParameters ¶meters,
|
||||
std::string &pbf_buffer) const
|
||||
{
|
||||
BOOST_ASSERT(parameters.IsValid());
|
||||
|
||||
@ -284,7 +286,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
|
||||
// Fetch all the segments that are in our bounding box.
|
||||
// This hits the OSRM StaticRTree
|
||||
const auto edges = facade.GetEdgesInBox(southwest, northeast);
|
||||
const auto edges = facade->GetEdgesInBox(southwest, northeast);
|
||||
|
||||
// Vector tiles encode properties as references to a common lookup table.
|
||||
// When we add a property to a "feature", we actually attach the index of the value
|
||||
@ -467,7 +469,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
{
|
||||
// Grab a copy of the geometry leading up to the intersection.
|
||||
first_geometry.clear();
|
||||
facade.GetUncompressedGeometry(source_ebn.second.packed_geometry_id, first_geometry);
|
||||
facade->GetUncompressedGeometry(source_ebn.second.packed_geometry_id, first_geometry);
|
||||
|
||||
// We earlier saved the source and target intersection nodes for every road section.
|
||||
// We can use the target node to find all road sections that lead away from
|
||||
@ -481,7 +483,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
continue;
|
||||
|
||||
// Find the connection between our source road and the target node
|
||||
EdgeID smaller_edge_id = facade.FindSmallestEdge(
|
||||
EdgeID smaller_edge_id = facade->FindSmallestEdge(
|
||||
source_ebn.first, target_ebn, [](const contractor::QueryEdge::EdgeData &data) {
|
||||
return data.forward;
|
||||
});
|
||||
@ -493,7 +495,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
// If we didn't find a forward edge, try for a backward one
|
||||
if (SPECIAL_EDGEID == smaller_edge_id)
|
||||
{
|
||||
smaller_edge_id = facade.FindSmallestEdge(
|
||||
smaller_edge_id = facade->FindSmallestEdge(
|
||||
target_ebn,
|
||||
source_ebn.first,
|
||||
[](const contractor::QueryEdge::EdgeData &data) { return data.backward; });
|
||||
@ -510,13 +512,13 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
// out of it, which should represent the first hop, which is the one
|
||||
// we want to find the turn.
|
||||
const auto &data =
|
||||
[this, smaller_edge_id, source_ebn, target_ebn, &unpacked_shortcut]() {
|
||||
const auto inner_data = facade.GetEdgeData(smaller_edge_id);
|
||||
[this, &facade, smaller_edge_id, source_ebn, target_ebn, &unpacked_shortcut]() {
|
||||
const auto inner_data = facade->GetEdgeData(smaller_edge_id);
|
||||
if (inner_data.shortcut)
|
||||
{
|
||||
unpacked_shortcut.clear();
|
||||
UnpackEdgeToEdges(
|
||||
facade, source_ebn.first, target_ebn, unpacked_shortcut);
|
||||
*facade, source_ebn.first, target_ebn, unpacked_shortcut);
|
||||
return unpacked_shortcut.front();
|
||||
}
|
||||
else
|
||||
@ -527,12 +529,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
// This is the geometry leading away from the intersection
|
||||
// (i.e. the geometry of the target edge-based-node)
|
||||
second_geometry.clear();
|
||||
facade.GetUncompressedGeometry(
|
||||
facade->GetUncompressedGeometry(
|
||||
edge_based_node_info.at(target_ebn).packed_geometry_id, second_geometry);
|
||||
|
||||
// Now, calculate the sum of the weight of all the segments.
|
||||
forward_weight_vector.clear();
|
||||
facade.GetUncompressedWeights(source_ebn.second.packed_geometry_id,
|
||||
facade->GetUncompressedWeights(source_ebn.second.packed_geometry_id,
|
||||
forward_weight_vector);
|
||||
const auto sum_node_weight = std::accumulate(
|
||||
forward_weight_vector.begin(), forward_weight_vector.end(), EdgeWeight{0});
|
||||
@ -552,9 +554,9 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
const auto node_via = source_ebn.second.target_intersection;
|
||||
const auto node_to = second_geometry.front();
|
||||
|
||||
const auto coord_from = facade.GetCoordinateOfNode(node_from);
|
||||
const auto coord_via = facade.GetCoordinateOfNode(node_via);
|
||||
const auto coord_to = facade.GetCoordinateOfNode(node_to);
|
||||
const auto coord_from = facade->GetCoordinateOfNode(node_from);
|
||||
const auto coord_via = facade->GetCoordinateOfNode(node_via);
|
||||
const auto coord_to = facade->GetCoordinateOfNode(node_to);
|
||||
|
||||
// Calculate the bearing that we approach the intersection at
|
||||
const auto angle_in = static_cast<int>(
|
||||
@ -613,11 +615,11 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
if (edge.forward_packed_geometry_id != SPECIAL_EDGEID)
|
||||
{
|
||||
forward_weight_vector.clear();
|
||||
facade.GetUncompressedWeights(edge.forward_packed_geometry_id, forward_weight_vector);
|
||||
facade->GetUncompressedWeights(edge.forward_packed_geometry_id, forward_weight_vector);
|
||||
forward_weight = forward_weight_vector[edge.fwd_segment_position];
|
||||
|
||||
forward_datasource_vector.clear();
|
||||
facade.GetUncompressedDatasources(edge.forward_packed_geometry_id,
|
||||
facade->GetUncompressedDatasources(edge.forward_packed_geometry_id,
|
||||
forward_datasource_vector);
|
||||
forward_datasource = forward_datasource_vector[edge.fwd_segment_position];
|
||||
|
||||
@ -627,7 +629,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
if (edge.reverse_packed_geometry_id != SPECIAL_EDGEID)
|
||||
{
|
||||
reverse_weight_vector.clear();
|
||||
facade.GetUncompressedWeights(edge.reverse_packed_geometry_id, reverse_weight_vector);
|
||||
facade->GetUncompressedWeights(edge.reverse_packed_geometry_id, reverse_weight_vector);
|
||||
|
||||
BOOST_ASSERT(edge.fwd_segment_position < reverse_weight_vector.size());
|
||||
|
||||
@ -635,7 +637,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
reverse_weight_vector[reverse_weight_vector.size() - edge.fwd_segment_position - 1];
|
||||
|
||||
reverse_datasource_vector.clear();
|
||||
facade.GetUncompressedDatasources(edge.reverse_packed_geometry_id,
|
||||
facade->GetUncompressedDatasources(edge.reverse_packed_geometry_id,
|
||||
reverse_datasource_vector);
|
||||
reverse_datasource = reverse_datasource_vector[reverse_datasource_vector.size() -
|
||||
edge.fwd_segment_position - 1];
|
||||
@ -647,7 +649,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
max_datasource_id = std::max(max_datasource_id, forward_datasource);
|
||||
max_datasource_id = std::max(max_datasource_id, reverse_datasource);
|
||||
|
||||
std::string name = facade.GetNameForID(edge.name_id);
|
||||
std::string name = facade->GetNameForID(edge.name_id);
|
||||
if (name_offsets.find(name) == name_offsets.end())
|
||||
{
|
||||
names.push_back(name);
|
||||
@ -687,8 +689,8 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
for (const auto &edge : edges)
|
||||
{
|
||||
// Get coordinates for start/end nodes of segment (NodeIDs u and v)
|
||||
const auto a = facade.GetCoordinateOfNode(edge.u);
|
||||
const auto b = facade.GetCoordinateOfNode(edge.v);
|
||||
const auto a = facade->GetCoordinateOfNode(edge.u);
|
||||
const auto b = facade->GetCoordinateOfNode(edge.v);
|
||||
// Calculate the length in meters
|
||||
const double length =
|
||||
osrm::util::coordinate_calculation::haversineDistance(a, b);
|
||||
@ -699,17 +701,17 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
std::uint8_t forward_datasource = 0;
|
||||
std::uint8_t reverse_datasource = 0;
|
||||
|
||||
std::string name = facade.GetNameForID(edge.name_id);
|
||||
std::string name = facade->GetNameForID(edge.name_id);
|
||||
|
||||
if (edge.forward_packed_geometry_id != SPECIAL_EDGEID)
|
||||
{
|
||||
forward_weight_vector.clear();
|
||||
facade.GetUncompressedWeights(edge.forward_packed_geometry_id,
|
||||
facade->GetUncompressedWeights(edge.forward_packed_geometry_id,
|
||||
forward_weight_vector);
|
||||
forward_weight = forward_weight_vector[edge.fwd_segment_position];
|
||||
|
||||
forward_datasource_vector.clear();
|
||||
facade.GetUncompressedDatasources(edge.forward_packed_geometry_id,
|
||||
facade->GetUncompressedDatasources(edge.forward_packed_geometry_id,
|
||||
forward_datasource_vector);
|
||||
forward_datasource = forward_datasource_vector[edge.fwd_segment_position];
|
||||
}
|
||||
@ -717,7 +719,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
if (edge.reverse_packed_geometry_id != SPECIAL_EDGEID)
|
||||
{
|
||||
reverse_weight_vector.clear();
|
||||
facade.GetUncompressedWeights(edge.reverse_packed_geometry_id,
|
||||
facade->GetUncompressedWeights(edge.reverse_packed_geometry_id,
|
||||
reverse_weight_vector);
|
||||
|
||||
BOOST_ASSERT(edge.fwd_segment_position < reverse_weight_vector.size());
|
||||
@ -726,7 +728,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
edge.fwd_segment_position - 1];
|
||||
|
||||
reverse_datasource_vector.clear();
|
||||
facade.GetUncompressedDatasources(edge.reverse_packed_geometry_id,
|
||||
facade->GetUncompressedDatasources(edge.reverse_packed_geometry_id,
|
||||
reverse_datasource_vector);
|
||||
reverse_datasource =
|
||||
reverse_datasource_vector[reverse_datasource_vector.size() -
|
||||
@ -884,7 +886,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
util::vector_tile::VARIANT_TAG);
|
||||
// Attribute value 1 == string type
|
||||
values_writer.add_string(util::vector_tile::VARIANT_TYPE_STRING,
|
||||
facade.GetDatasourceName(i));
|
||||
facade->GetDatasourceName(i));
|
||||
}
|
||||
for (auto value : used_line_ints)
|
||||
{
|
||||
|
@ -114,7 +114,8 @@ SCC_Component SplitUnaccessibleLocations(const std::size_t number_of_locations,
|
||||
return SCC_Component(std::move(components), std::move(range));
|
||||
}
|
||||
|
||||
InternalRouteResult TripPlugin::ComputeRoute(const std::vector<PhantomNode> &snapped_phantoms,
|
||||
InternalRouteResult TripPlugin::ComputeRoute(const datafacade::BaseDataFacade& facade,
|
||||
const std::vector<PhantomNode> &snapped_phantoms,
|
||||
const std::vector<NodeID> &trip)
|
||||
{
|
||||
InternalRouteResult min_route;
|
||||
@ -134,13 +135,14 @@ InternalRouteResult TripPlugin::ComputeRoute(const std::vector<PhantomNode> &sna
|
||||
}
|
||||
BOOST_ASSERT(min_route.segment_end_coordinates.size() == trip.size());
|
||||
|
||||
shortest_path(min_route.segment_end_coordinates, {false}, min_route);
|
||||
shortest_path(facade, min_route.segment_end_coordinates, {false}, min_route);
|
||||
|
||||
BOOST_ASSERT_MSG(min_route.shortest_path_length < INVALID_EDGE_WEIGHT, "unroutable route");
|
||||
return min_route;
|
||||
}
|
||||
|
||||
Status TripPlugin::HandleRequest(const api::TripParameters ¶meters,
|
||||
Status TripPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::TripParameters ¶meters,
|
||||
util::json::Object &json_result)
|
||||
{
|
||||
BOOST_ASSERT(parameters.IsValid());
|
||||
@ -157,7 +159,7 @@ Status TripPlugin::HandleRequest(const api::TripParameters ¶meters,
|
||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
||||
}
|
||||
|
||||
auto phantom_node_pairs = GetPhantomNodes(parameters);
|
||||
auto phantom_node_pairs = GetPhantomNodes(*facade, parameters);
|
||||
if (phantom_node_pairs.size() != parameters.coordinates.size())
|
||||
{
|
||||
return Error("NoSegment",
|
||||
@ -173,7 +175,7 @@ Status TripPlugin::HandleRequest(const api::TripParameters ¶meters,
|
||||
|
||||
// compute the duration table of all phantom nodes
|
||||
const auto result_table = util::DistTableWrapper<EdgeWeight>(
|
||||
duration_table(snapped_phantoms, {}, {}), number_of_locations);
|
||||
duration_table(*facade, snapped_phantoms, {}, {}), number_of_locations);
|
||||
|
||||
if (result_table.size() == 0)
|
||||
{
|
||||
@ -231,10 +233,10 @@ Status TripPlugin::HandleRequest(const api::TripParameters ¶meters,
|
||||
routes.reserve(trips.size());
|
||||
for (const auto &trip : trips)
|
||||
{
|
||||
routes.push_back(ComputeRoute(snapped_phantoms, trip));
|
||||
routes.push_back(ComputeRoute(*facade, snapped_phantoms, trip));
|
||||
}
|
||||
|
||||
api::TripAPI trip_api{BasePlugin::facade, parameters};
|
||||
api::TripAPI trip_api{*facade, parameters};
|
||||
trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result);
|
||||
|
||||
return Status::Ok;
|
||||
|
@ -21,13 +21,14 @@ namespace engine
|
||||
namespace plugins
|
||||
{
|
||||
|
||||
ViaRoutePlugin::ViaRoutePlugin(datafacade::BaseDataFacade &facade_, int max_locations_viaroute)
|
||||
: BasePlugin(facade_), shortest_path(&facade_, heaps), alternative_path(&facade_, heaps),
|
||||
direct_shortest_path(&facade_, heaps), max_locations_viaroute(max_locations_viaroute)
|
||||
ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute)
|
||||
: shortest_path(heaps), alternative_path(heaps), direct_shortest_path(heaps),
|
||||
max_locations_viaroute(max_locations_viaroute)
|
||||
{
|
||||
}
|
||||
|
||||
Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameters,
|
||||
Status ViaRoutePlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
|
||||
const api::RouteParameters &route_parameters,
|
||||
util::json::Object &json_result)
|
||||
{
|
||||
BOOST_ASSERT(route_parameters.IsValid());
|
||||
@ -47,7 +48,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
||||
}
|
||||
|
||||
auto phantom_node_pairs = GetPhantomNodes(route_parameters);
|
||||
auto phantom_node_pairs = GetPhantomNodes(*facade, route_parameters);
|
||||
if (phantom_node_pairs.size() != route_parameters.coordinates.size())
|
||||
{
|
||||
return Error("NoSegment",
|
||||
@ -61,7 +62,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
|
||||
const bool continue_straight_at_waypoint = route_parameters.continue_straight
|
||||
? *route_parameters.continue_straight
|
||||
: facade.GetContinueStraightDefault();
|
||||
: facade->GetContinueStraightDefault();
|
||||
|
||||
InternalRouteResult raw_route;
|
||||
auto build_phantom_pairs = [&raw_route, continue_straight_at_waypoint](
|
||||
@ -85,18 +86,18 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
|
||||
if (1 == raw_route.segment_end_coordinates.size())
|
||||
{
|
||||
if (route_parameters.alternatives && facade.GetCoreSize() == 0)
|
||||
if (route_parameters.alternatives && facade->GetCoreSize() == 0)
|
||||
{
|
||||
alternative_path(raw_route.segment_end_coordinates.front(), raw_route);
|
||||
alternative_path(*facade, raw_route.segment_end_coordinates.front(), raw_route);
|
||||
}
|
||||
else
|
||||
{
|
||||
direct_shortest_path(raw_route.segment_end_coordinates, raw_route);
|
||||
direct_shortest_path(*facade, raw_route.segment_end_coordinates, raw_route);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shortest_path(
|
||||
shortest_path(*facade,
|
||||
raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route);
|
||||
}
|
||||
|
||||
@ -104,7 +105,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
// allow for connection in one direction.
|
||||
if (raw_route.is_valid())
|
||||
{
|
||||
api::RouteAPI route_api{BasePlugin::facade, route_parameters};
|
||||
api::RouteAPI route_api{*facade, route_parameters};
|
||||
route_api.MakeResponse(raw_route, json_result);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user