Passed ResultT down to engine plugins, so now they can form replies in different formats.

This commit is contained in:
Denis Chaplygin
2019-08-02 17:40:55 +03:00
parent f6f86b2a52
commit 75aadb0f3f
32 changed files with 136 additions and 99 deletions
+7 -6
View File
@@ -21,11 +21,12 @@ NearestPlugin::NearestPlugin(const int max_results_) : max_results{max_results_}
Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::NearestParameters &params,
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);