Port OSRM, Engine and Datafacades to be algorithm aware

This commit is contained in:
Patrick Niklaus
2017-01-09 20:40:33 +00:00
committed by Patrick Niklaus
parent 71e95c92b6
commit 2fa8d0f534
47 changed files with 1384 additions and 1047 deletions
+12 -11
View File
@@ -52,11 +52,10 @@ bool IsSupportedParameterCombination(const bool fixed_start,
// given the node order in which to visit, compute the actual route (with geometry, travel time and
// so on) and return the result
InternalRouteResult
TripPlugin::ComputeRoute(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
const std::vector<PhantomNode> &snapped_phantoms,
const std::vector<NodeID> &trip,
const bool roundtrip) const
InternalRouteResult TripPlugin::ComputeRoute(const RoutingAlgorithmsInterface &algorithms,
const std::vector<PhantomNode> &snapped_phantoms,
const std::vector<NodeID> &trip,
const bool roundtrip) const
{
InternalRouteResult min_route;
// given the final trip, compute total duration and return the route and location permutation
@@ -86,7 +85,7 @@ TripPlugin::ComputeRoute(const std::shared_ptr<const datafacade::BaseDataFacade>
BOOST_ASSERT(min_route.segment_end_coordinates.size() == trip.size() - 1);
}
shortest_path(facade, min_route.segment_end_coordinates, {false}, min_route);
algorithms.ShortestRouting(min_route.segment_end_coordinates, {false}, min_route);
BOOST_ASSERT_MSG(min_route.shortest_path_length < INVALID_EDGE_WEIGHT, "unroutable route");
return min_route;
}
@@ -143,7 +142,8 @@ void ManipulateTableForFSE(const std::size_t source_id,
//********* End of changes to table *************************************
}
Status TripPlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
Status TripPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFacadeBase &facade,
const RoutingAlgorithmsInterface &algorithms,
const api::TripParameters &parameters,
util::json::Object &json_result) const
{
@@ -179,7 +179,7 @@ Status TripPlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
return Error("InvalidValue", "Invalid coordinate value.", json_result);
}
auto phantom_node_pairs = GetPhantomNodes(*facade, parameters);
auto phantom_node_pairs = GetPhantomNodes(facade, parameters);
if (phantom_node_pairs.size() != number_of_locations)
{
return Error("NoSegment",
@@ -201,7 +201,7 @@ Status TripPlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
// compute the duration table of all phantom nodes
auto result_table = util::DistTableWrapper<EdgeWeight>(
duration_table(facade, snapped_phantoms, {}, {}), number_of_locations);
algorithms.ManyToManyRouting(snapped_phantoms, {}, {}), number_of_locations);
if (result_table.size() == 0)
{
@@ -250,12 +250,13 @@ Status TripPlugin::HandleRequest(const std::shared_ptr<const datafacade::BaseDat
}
// get the route when visiting all destinations in optimized order
InternalRouteResult route = ComputeRoute(facade, snapped_phantoms, trip, parameters.roundtrip);
InternalRouteResult route =
ComputeRoute(algorithms, snapped_phantoms, trip, parameters.roundtrip);
// get api response
const std::vector<std::vector<NodeID>> trips = {trip};
const std::vector<InternalRouteResult> routes = {route};
api::TripAPI trip_api{*facade, parameters};
api::TripAPI trip_api{facade, parameters};
trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result);
return Status::Ok;