Return an array with meta-data for each coordinate.
Currently supports duration and distance for each coordinate. This is particularly useful in map-matching, comparing how a trip progresses compared to a real GPS trace that is map-matched.
This commit is contained in:
committed by
Patrick Niklaus
parent
0f2bb5dde5
commit
fa525ad610
@@ -52,6 +52,7 @@ struct MatchParameters : public RouteParameters
|
||||
{
|
||||
MatchParameters()
|
||||
: RouteParameters(false,
|
||||
false,
|
||||
false,
|
||||
RouteParameters::GeometriesType::Polyline,
|
||||
RouteParameters::OverviewType::Simplified,
|
||||
|
||||
@@ -176,9 +176,33 @@ class RouteAPI : public BaseAPI
|
||||
});
|
||||
}
|
||||
|
||||
return json::makeRoute(route,
|
||||
auto result = json::makeRoute(route,
|
||||
json::makeRouteLegs(std::move(legs), std::move(step_geometries)),
|
||||
std::move(json_overview));
|
||||
|
||||
if (parameters.annotation)
|
||||
{
|
||||
util::json::Array durations;
|
||||
util::json::Array distances;
|
||||
for (const auto idx : util::irange<std::size_t>(0UL, leg_geometries.size()))
|
||||
{
|
||||
auto &leg_geometry = leg_geometries[idx];
|
||||
std::for_each(leg_geometry.annotations.begin(),
|
||||
leg_geometry.annotations.end(),
|
||||
[this, &durations, &distances](const guidance::LegGeometry::Annotation &step) {
|
||||
durations.values.push_back(step.duration);
|
||||
distances.values.push_back(step.distance);
|
||||
});
|
||||
}
|
||||
|
||||
util::json::Object details;
|
||||
details.values["distance"] = std::move(distances);
|
||||
details.values["duration"] = std::move(durations);
|
||||
|
||||
result.values["annotation"] = std::move(details);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const RouteParameters ¶meters;
|
||||
|
||||
@@ -72,17 +72,20 @@ struct RouteParameters : public BaseParameters
|
||||
template <typename... Args>
|
||||
RouteParameters(const bool steps_,
|
||||
const bool alternatives_,
|
||||
const bool annotation_,
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
geometries{geometries_}, overview{overview_}, continue_straight{continue_straight_}
|
||||
annotation{annotation_}, geometries{geometries_}, overview{overview_},
|
||||
continue_straight{continue_straight_}
|
||||
{
|
||||
}
|
||||
|
||||
bool steps = false;
|
||||
bool alternatives = false;
|
||||
bool annotation = false;
|
||||
GeometriesType geometries = GeometriesType::Polyline;
|
||||
OverviewType overview = OverviewType::Simplified;
|
||||
boost::optional<bool> continue_straight;
|
||||
|
||||
Reference in New Issue
Block a user