MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / HandleRequest

Method HandleRequest

src/engine/plugins/nearest.cpp:18–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
19 const api::NearestParameters &params,
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

Callers

nothing calls this directly

Calls 5

to_stringFunction · 0.85
IsValidMethod · 0.45
sizeMethod · 0.45
frontMethod · 0.45
MakeResponseMethod · 0.45

Tested by

no test coverage detected