use lambda instead of bindy
This commit is contained in:
parent
ab91a05680
commit
c885d03830
@ -86,7 +86,7 @@ class RouteAPI : public BaseAPI
|
||||
annotations_store.values.reserve(leg.annotations.size());
|
||||
std::for_each(leg.annotations.begin(),
|
||||
leg.annotations.end(),
|
||||
[Get, &annotations_store](const guidance::LegGeometry::Annotation &step) {
|
||||
[Get, &annotations_store](const auto &step) {
|
||||
annotations_store.values.push_back(Get(step));
|
||||
});
|
||||
return annotations_store;
|
||||
@ -237,32 +237,31 @@ class RouteAPI : public BaseAPI
|
||||
|
||||
if (parameters.annotations_type & RouteParameters::AnnotationsType::Duration)
|
||||
{
|
||||
annotation.values["duration"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
std::bind(&guidance::LegGeometry::Annotation::duration,
|
||||
std::placeholders::_1));
|
||||
annotation.values["duration"] = GetAnnotations(
|
||||
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.duration;
|
||||
});
|
||||
}
|
||||
|
||||
if (parameters.annotations_type & RouteParameters::AnnotationsType::Distance)
|
||||
{
|
||||
annotation.values["distance"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
std::bind(&guidance::LegGeometry::Annotation::distance,
|
||||
std::placeholders::_1));
|
||||
annotation.values["distance"] = GetAnnotations(
|
||||
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.distance;
|
||||
});
|
||||
}
|
||||
if (parameters.annotations_type & RouteParameters::AnnotationsType::Weight)
|
||||
{
|
||||
annotation.values["weight"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
std::bind(&guidance::LegGeometry::Annotation::weight,
|
||||
std::placeholders::_1));
|
||||
annotation.values["weight"] = GetAnnotations(
|
||||
leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno) { return anno.weight; });
|
||||
}
|
||||
if (parameters.annotations_type & RouteParameters::AnnotationsType::Datasources)
|
||||
{
|
||||
annotation.values["datasources"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
std::bind(&guidance::LegGeometry::Annotation::datasource,
|
||||
std::placeholders::_1));
|
||||
annotation.values["datasources"] = GetAnnotations(
|
||||
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.datasource;
|
||||
});
|
||||
}
|
||||
if (parameters.annotations_type & RouteParameters::AnnotationsType::Nodes)
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ struct RouteParameters : public BaseParameters
|
||||
const boost::optional<bool> continue_straight_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
annotations_type{annotations_}, annotations{true}, geometries{geometries_},
|
||||
annotations_type{annotations_}, annotations{annotations_ == AnnotationsType::None ? false : true}, geometries{geometries_},
|
||||
overview{overview_}, continue_straight{continue_straight_}
|
||||
{
|
||||
}
|
||||
@ -152,6 +152,12 @@ inline RouteParameters::AnnotationsType operator|(RouteParameters::AnnotationsTy
|
||||
static_cast<std::underlying_type_t<RouteParameters::AnnotationsType>>(rhs));
|
||||
}
|
||||
|
||||
inline RouteParameters::AnnotationsType operator|=(RouteParameters::AnnotationsType lhs,
|
||||
RouteParameters::AnnotationsType rhs)
|
||||
{
|
||||
return lhs = lhs | rhs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
|
||||
engine::api::RouteParameters::AnnotationsType &route_param) {
|
||||
route_parameters.annotations_type = route_parameters.annotations_type | route_param;
|
||||
route_parameters.annotations = route_parameters.annotations_type != engine::api::RouteParameters::AnnotationsType::None;
|
||||
return route_parameters;
|
||||
};
|
||||
|
||||
geometries_type.add("geojson", engine::api::RouteParameters::GeometriesType::GeoJSON)(
|
||||
|
Loading…
Reference in New Issue
Block a user