add unit test for annotations=true returning all annotations

This commit is contained in:
karenzshea
2017-02-13 12:53:05 +01:00
committed by Patrick Niklaus
parent a31f401995
commit e75278f9c2
4 changed files with 47 additions and 19 deletions
+11 -11
View File
@@ -228,21 +228,23 @@ class RouteAPI : public BaseAPI
std::vector<util::json::Object> annotations;
if (parameters.annotations_type != RouteParameters::AnnotationsType::None ||
parameters.annotations == true)
// To maintain support for uses of the old default constructors, we check
// if annotations property was set manually after default construction
auto requested_annotations = parameters.annotations_type;
if ((parameters.annotations == true) &&
(parameters.annotations_type == RouteParameters::AnnotationsType::None))
{
auto requested_annotations = parameters.annotations_type;
if ((parameters.annotations == true) &&
(parameters.annotations_type == RouteParameters::AnnotationsType::None))
{
requested_annotations = RouteParameters::AnnotationsType::All;
}
requested_annotations = RouteParameters::AnnotationsType::All;
}
if (requested_annotations != RouteParameters::AnnotationsType::None)
{
for (const auto idx : util::irange<std::size_t>(0UL, leg_geometries.size()))
{
auto &leg_geometry = leg_geometries[idx];
util::json::Object annotation;
// AnnotationsType uses bit flags, & operator checks if a property is set
if (parameters.annotations_type & RouteParameters::AnnotationsType::Speed)
{
annotation.values["speed"] = GetAnnotations(
@@ -251,15 +253,13 @@ class RouteAPI : public BaseAPI
});
}
// AnnotationsType uses bit flags, & operator checks if a property is set
if (ReqAnnotations & RouteParameters::AnnotationsType::Duration)
if (requested_annotations & RouteParameters::AnnotationsType::Duration)
{
annotation.values["duration"] = GetAnnotations(
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
return anno.duration;
});
}
if (requested_annotations & RouteParameters::AnnotationsType::Distance)
{
annotation.values["distance"] = GetAnnotations(