Passed ResultT down to engine plugins, so now they can form replies in different formats.
This commit is contained in:
@@ -28,16 +28,18 @@ ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute, int max_alternatives)
|
||||
|
||||
Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
const api::RouteParameters &route_parameters,
|
||||
util::json::Object &json_result) const
|
||||
osrm::engine::api::ResultT &result) const
|
||||
{
|
||||
BOOST_ASSERT(route_parameters.IsValid());
|
||||
|
||||
auto& json_result = result.get<util::json::Object>();
|
||||
|
||||
if (!algorithms.HasShortestPathSearch() && route_parameters.coordinates.size() > 2)
|
||||
{
|
||||
return Error("NotImplemented",
|
||||
"Shortest path search is not implemented for the chosen search algorithm. "
|
||||
"Only two coordinates supported.",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch())
|
||||
@@ -45,7 +47,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
return Error(
|
||||
"NotImplemented",
|
||||
"Direct shortest path search is not implemented for the chosen search algorithm.",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
if (max_locations_viaroute > 0 &&
|
||||
@@ -55,7 +57,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
"Number of entries " + std::to_string(route_parameters.coordinates.size()) +
|
||||
" is higher than current maximum (" +
|
||||
std::to_string(max_locations_viaroute) + ")",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
// Takes care of alternatives=n and alternatives=true
|
||||
@@ -65,12 +67,12 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
return Error("TooBig",
|
||||
"Requested number of alternatives is higher than current maximum (" +
|
||||
std::to_string(max_alternatives) + ")",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
if (!CheckAllCoordinates(route_parameters.coordinates))
|
||||
{
|
||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
||||
return Error("InvalidValue", "Invalid coordinate value.", result);
|
||||
}
|
||||
|
||||
// Error: first and last points should be waypoints
|
||||
@@ -80,10 +82,10 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
{
|
||||
return Error("InvalidValue",
|
||||
"First and last coordinates must be specified as waypoints.",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
if (!CheckAlgorithms(route_parameters, algorithms, json_result))
|
||||
if (!CheckAlgorithms(route_parameters, algorithms, result))
|
||||
return Status::Error;
|
||||
|
||||
const auto &facade = algorithms.GetFacade();
|
||||
@@ -93,7 +95,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
return Error("NoSegment",
|
||||
std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(phantom_node_pairs.size()),
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size());
|
||||
|
||||
@@ -175,11 +177,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
|
||||
|
||||
if (not_in_same_component)
|
||||
{
|
||||
return Error("NoRoute", "Impossible route between points", json_result);
|
||||
return Error("NoRoute", "Impossible route between points", result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Error("NoRoute", "No route found between points", json_result);
|
||||
return Error("NoRoute", "No route found between points", result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user