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

Method HandleRequest

src/engine/plugins/viaroute.cpp:26–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
27 const api::RouteParameters &route_parameters,
28 osrm::engine::api::ResultT &result) const
29{
30 BOOST_ASSERT(route_parameters.IsValid());
31
32 if (!algorithms.HasShortestPathSearch() && route_parameters.coordinates.size() > 2)
33 {
34 return Error("NotImplemented",
35 "Shortest path search is not implemented for the chosen search algorithm. "
36 "Only two coordinates supported.",
37 result);
38 }
39
40 if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch())
41 {
42 return Error(
43 "NotImplemented",
44 "Direct shortest path search is not implemented for the chosen search algorithm.",
45 result);
46 }
47
48 if (max_locations_viaroute > 0 &&
49 (static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute))
50 {
51 return Error("TooBig",
52 "Number of entries " + std::to_string(route_parameters.coordinates.size()) +
53 " is higher than current maximum (" +
54 std::to_string(max_locations_viaroute) + ")",
55 result);
56 }
57
58 // Takes care of alternatives=n and alternatives=true
59 if ((route_parameters.number_of_alternatives > static_cast<unsigned>(max_alternatives)) ||
60 (route_parameters.alternatives && max_alternatives == 0))
61 {
62 return Error("TooBig",
63 "Requested number of alternatives is higher than current maximum (" +
64 std::to_string(max_alternatives) + ")",
65 result);
66 }
67
68 if (!CheckAllCoordinates(route_parameters.coordinates))
69 {
70 return Error("InvalidValue", "Invalid coordinate value.", result);
71 }
72
73 // Error: first and last points should be waypoints
74 if (!route_parameters.waypoints.empty() &&
75 (route_parameters.waypoints[0] != 0 ||
76 route_parameters.waypoints.back() != (route_parameters.coordinates.size() - 1)))
77 {
78 return Error(
79 "InvalidValue", "First and last coordinates must be specified as waypoints.", result);
80 }
81
82 if (!CheckAlgorithms(route_parameters, algorithms, result))
83 return Status::Error;

Callers

nothing calls this directly

Calls 15

to_stringFunction · 0.85
candidatesHaveComponentFunction · 0.85
HasShortestPathSearchMethod · 0.80
AlternativePathSearchMethod · 0.80
ShortestPathSearchMethod · 0.80
is_validMethod · 0.80
IsValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected