Passed ResultT down to engine plugins, so now they can form replies in different formats.
This commit is contained in:
@@ -21,11 +21,12 @@ NearestPlugin::NearestPlugin(const int max_results_) : max_results{max_results_}
|
||||
|
||||
Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
const api::NearestParameters ¶ms,
|
||||
util::json::Object &json_result) const
|
||||
osrm::engine::api::ResultT &result) const
|
||||
{
|
||||
BOOST_ASSERT(params.IsValid());
|
||||
|
||||
if (!CheckAlgorithms(params, algorithms, json_result))
|
||||
auto& json_result = result.get<util::json::Object>();
|
||||
if (!CheckAlgorithms(params, algorithms, result))
|
||||
return Status::Error;
|
||||
|
||||
const auto &facade = algorithms.GetFacade();
|
||||
@@ -36,22 +37,22 @@ Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms
|
||||
return Error("TooBig",
|
||||
"Number of results " + std::to_string(params.number_of_results) +
|
||||
" is higher than current maximum (" + std::to_string(max_results) + ")",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
if (!CheckAllCoordinates(params.coordinates))
|
||||
return Error("InvalidOptions", "Coordinates are invalid", json_result);
|
||||
return Error("InvalidOptions", "Coordinates are invalid", result);
|
||||
|
||||
if (params.coordinates.size() != 1)
|
||||
{
|
||||
return Error("InvalidOptions", "Only one input coordinate is supported", json_result);
|
||||
return Error("InvalidOptions", "Only one input coordinate is supported", result);
|
||||
}
|
||||
|
||||
auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results);
|
||||
|
||||
if (phantom_nodes.front().size() == 0)
|
||||
{
|
||||
return Error("NoSegment", "Could not find a matching segments for coordinate", json_result);
|
||||
return Error("NoSegment", "Could not find a matching segments for coordinate", result);
|
||||
}
|
||||
BOOST_ASSERT(phantom_nodes.front().size() > 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user