Passed ResultT down to engine plugins, so now they can form replies in different formats.
This commit is contained in:
@@ -112,16 +112,17 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
|
||||
|
||||
Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
const api::MatchParameters ¶meters,
|
||||
util::json::Object &json_result) const
|
||||
osrm::engine::api::ResultT &result) const
|
||||
{
|
||||
auto& json_result = result.get<util::json::Object>();
|
||||
if (!algorithms.HasMapMatching())
|
||||
{
|
||||
return Error("NotImplemented",
|
||||
"Map matching is not implemented for the chosen search algorithm.",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
if (!CheckAlgorithms(parameters, algorithms, json_result))
|
||||
if (!CheckAlgorithms(parameters, algorithms, result))
|
||||
return Status::Error;
|
||||
|
||||
const auto &facade = algorithms.GetFacade();
|
||||
@@ -132,12 +133,12 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
if (max_locations_map_matching > 0 &&
|
||||
static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching)
|
||||
{
|
||||
return Error("TooBig", "Too many trace coordinates", json_result);
|
||||
return Error("TooBig", "Too many trace coordinates", result);
|
||||
}
|
||||
|
||||
if (!CheckAllCoordinates(parameters.coordinates))
|
||||
{
|
||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
||||
return Error("InvalidValue", "Invalid coordinate value.", result);
|
||||
}
|
||||
|
||||
if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
|
||||
@@ -148,7 +149,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
return *radius > max_radius_map_matching;
|
||||
}))
|
||||
{
|
||||
return Error("TooBig", "Radius search size is too large for map matching.", json_result);
|
||||
return Error("TooBig", "Radius search size is too large for map matching.", result);
|
||||
}
|
||||
|
||||
// Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
|
||||
@@ -159,7 +160,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
if (!time_increases_monotonically)
|
||||
{
|
||||
return Error(
|
||||
"InvalidValue", "Timestamps need to be monotonically increasing.", json_result);
|
||||
"InvalidValue", "Timestamps need to be monotonically increasing.", result);
|
||||
}
|
||||
|
||||
SubMatchingList sub_matchings;
|
||||
@@ -182,7 +183,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
{
|
||||
return Error("InvalidValue",
|
||||
"First and last coordinates must be specified as waypoints.",
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
// assuming radius is the standard deviation of a normal distribution
|
||||
@@ -225,7 +226,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
{
|
||||
return Error("NoSegment",
|
||||
std::string("Could not find a matching segment for any coordinate."),
|
||||
json_result);
|
||||
result);
|
||||
}
|
||||
|
||||
// call the actual map matching
|
||||
@@ -238,13 +239,13 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
|
||||
if (sub_matchings.size() == 0)
|
||||
{
|
||||
return Error("NoMatch", "Could not match the trace.", json_result);
|
||||
return Error("NoMatch", "Could not match the trace.", result);
|
||||
}
|
||||
|
||||
// trace was split, we don't support the waypoints parameter across multiple match objects
|
||||
if (sub_matchings.size() > 1 && !parameters.waypoints.empty())
|
||||
{
|
||||
return Error("NoMatch", "Could not match the trace with the given waypoints.", json_result);
|
||||
return Error("NoMatch", "Could not match the trace with the given waypoints.", result);
|
||||
}
|
||||
|
||||
// Error: Check if user-supplied waypoints can be found in the resulting matches
|
||||
@@ -261,7 +262,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
if (!tidied_waypoints.empty())
|
||||
{
|
||||
return Error(
|
||||
"NoMatch", "Requested waypoint parameter could not be matched.", json_result);
|
||||
"NoMatch", "Requested waypoint parameter could not be matched.", result);
|
||||
}
|
||||
}
|
||||
// we haven't errored yet, only allow leg collapsing if it was originally requested
|
||||
|
||||
Reference in New Issue
Block a user