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

Method HandleRequest

src/engine/plugins/match.cpp:103–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
104 const api::MatchParameters &parameters,
105 osrm::engine::api::ResultT &result) const
106{
107 if (!algorithms.HasMapMatching())
108 {
109 return Error("NotImplemented",
110 "Map matching is not implemented for the chosen search algorithm.",
111 result);
112 }
113
114 if (!CheckAlgorithms(parameters, algorithms, result))
115 return Status::Error;
116
117 const auto &facade = algorithms.GetFacade();
118
119 BOOST_ASSERT(parameters.IsValid());
120
121 // enforce maximum number of locations for performance reasons
122 if (max_locations_map_matching > 0 &&
123 static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching)
124 {
125 return Error("TooBig", "Too many trace coordinates", result);
126 }
127
128 if (!CheckAllCoordinates(parameters.coordinates))
129 {
130 return Error("InvalidValue", "Invalid coordinate value.", result);
131 }
132
133 if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
134 parameters.radiuses.end(),
135 [&](const auto &radius)
136 {
137 if (!radius)
138 return false;
139 return *radius > max_radius_map_matching;
140 }))
141 {
142 return Error("TooBig", "Radius search size is too large for map matching.", result);
143 }
144
145 // Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
146 // last, less_equal)` checking `greater` in reverse meets irreflexive requirements.
147 const auto time_increases_monotonically = std::is_sorted(
148 parameters.timestamps.rbegin(), parameters.timestamps.rend(), std::greater<>{});
149
150 if (!time_increases_monotonically)
151 {
152 return Error("InvalidValue", "Timestamps need to be monotonically increasing.", result);
153 }
154
155 SubMatchingList sub_matchings;
156 api::tidy::Result tidied;
157 if (parameters.tidy)
158 {
159 // Transparently tidy match parameters, do map matching on tidied parameters.
160 // Then use the mapping to restore the original <-> tidied relationship.

Callers

nothing calls this directly

Calls 15

tidyFunction · 0.85
keep_allFunction · 0.85
filterCandidatesFunction · 0.85
HasMapMatchingMethod · 0.80
MapMatchingMethod · 0.80
ShortestPathSearchMethod · 0.80
IsValidMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
rbeginMethod · 0.45

Tested by

no test coverage detected