| 16 | } |
| 17 | |
| 18 | Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, |
| 19 | const api::NearestParameters ¶ms, |
| 20 | osrm::engine::api::ResultT &result) const |
| 21 | { |
| 22 | BOOST_ASSERT(params.IsValid()); |
| 23 | |
| 24 | if (!CheckAlgorithms(params, algorithms, result)) |
| 25 | return Status::Error; |
| 26 | |
| 27 | const auto &facade = algorithms.GetFacade(); |
| 28 | |
| 29 | if (max_results > 0 && |
| 30 | (boost::numeric_cast<std::int64_t>(params.number_of_results) > max_results)) |
| 31 | { |
| 32 | return Error("TooBig", |
| 33 | "Number of results " + std::to_string(params.number_of_results) + |
| 34 | " is higher than current maximum (" + std::to_string(max_results) + ")", |
| 35 | result); |
| 36 | } |
| 37 | |
| 38 | if (!CheckAllCoordinates(params.coordinates)) |
| 39 | return Error("InvalidOptions", "Coordinates are invalid", result); |
| 40 | |
| 41 | if (params.coordinates.size() != 1) |
| 42 | { |
| 43 | return Error("InvalidOptions", "Only one input coordinate is supported", result); |
| 44 | } |
| 45 | |
| 46 | auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results); |
| 47 | |
| 48 | if (phantom_nodes.front().size() == 0) |
| 49 | { |
| 50 | return Error("NoSegment", "Could not find a matching segments for coordinate", result); |
| 51 | } |
| 52 | BOOST_ASSERT(phantom_nodes.front().size() > 0); |
| 53 | |
| 54 | api::NearestAPI nearest_api(facade, params); |
| 55 | nearest_api.MakeResponse(phantom_nodes, result); |
| 56 | |
| 57 | return Status::Ok; |
| 58 | } |
| 59 | } // namespace osrm::engine::plugins |
nothing calls this directly
no test coverage detected