From c7ce758e1cfeb4ac6dc9f98d04235df5dcfe228a Mon Sep 17 00:00:00 2001 From: karenzshea Date: Fri, 10 Feb 2017 17:26:27 +0100 Subject: [PATCH] parse parameters.annotations into AnnotationsType::All --- include/engine/api/route_api.hpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index 32549bf1e..499c59d99 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -228,8 +228,16 @@ class RouteAPI : public BaseAPI std::vector annotations; - if (parameters.annotations_type != RouteParameters::AnnotationsType::None) + if (parameters.annotations_type != RouteParameters::AnnotationsType::None || + parameters.annotations == true) { + auto requested_annotations = parameters.annotations_type; + if ((parameters.annotations == true) && + (parameters.annotations_type == RouteParameters::AnnotationsType::None)) + { + requested_annotations = RouteParameters::AnnotationsType::All; + } + for (const auto idx : util::irange(0UL, leg_geometries.size())) { auto &leg_geometry = leg_geometries[idx]; @@ -243,7 +251,8 @@ class RouteAPI : public BaseAPI }); } - if (parameters.annotations_type & RouteParameters::AnnotationsType::Duration) + // AnnotationsType uses bit flags, & operator checks if a property is set + if (ReqAnnotations & RouteParameters::AnnotationsType::Duration) { annotation.values["duration"] = GetAnnotations( leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { @@ -251,27 +260,27 @@ class RouteAPI : public BaseAPI }); } - if (parameters.annotations_type & RouteParameters::AnnotationsType::Distance) + if (requested_annotations & RouteParameters::AnnotationsType::Distance) { annotation.values["distance"] = GetAnnotations( leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { return anno.distance; }); } - if (parameters.annotations_type & RouteParameters::AnnotationsType::Weight) + if (requested_annotations & RouteParameters::AnnotationsType::Weight) { annotation.values["weight"] = GetAnnotations( leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { return anno.weight; }); } - if (parameters.annotations_type & RouteParameters::AnnotationsType::Datasources) + if (requested_annotations & RouteParameters::AnnotationsType::Datasources) { annotation.values["datasources"] = GetAnnotations( leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { return anno.datasource; }); } - if (parameters.annotations_type & RouteParameters::AnnotationsType::Nodes) + if (requested_annotations & RouteParameters::AnnotationsType::Nodes) { util::json::Array nodes; nodes.values.reserve(leg_geometry.osm_node_ids.size());