Skip to content

Commit

Permalink
copy parameters obj to make modifiable
Browse files Browse the repository at this point in the history
  • Loading branch information
karenzshea committed Feb 13, 2017
1 parent 14337fd commit 3b02154
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions include/engine/api/route_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,45 +228,50 @@ class RouteAPI : public BaseAPI

std::vector<util::json::Object> annotations;

if (parameters.annotations_type != RouteParameters::AnnotationsType::None || parameters.annotations == true)
if (parameters.annotations_type != RouteParameters::AnnotationsType::None ||
parameters.annotations == true)
{
if (parameters.annotations == true)
parameters.annotations_type = RouteParameters::AnnotationsType::All;
auto params = parameters;
if ((parameters.annotations == true) & (parameters.annotations_type &
RouteParameters::AnnotationsType::None))
{
params.annotations_type = RouteParameters::AnnotationsType::All;
}

for (const auto idx : util::irange<std::size_t>(0UL, leg_geometries.size()))
{
auto &leg_geometry = leg_geometries[idx];
util::json::Object annotation;

if (parameters.annotations_type & RouteParameters::AnnotationsType::Duration)
if (params.annotations_type & RouteParameters::AnnotationsType::Duration)
{
annotation.values["duration"] = GetAnnotations(
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
return anno.duration;
});
}

if (parameters.annotations_type & RouteParameters::AnnotationsType::Distance)
if (params.annotations_type & 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 (params.annotations_type & 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 (params.annotations_type & 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 (params.annotations_type & RouteParameters::AnnotationsType::Nodes)
{
util::json::Array nodes;
nodes.values.reserve(leg_geometry.osm_node_ids.size());
Expand Down

0 comments on commit 3b02154

Please sign in to comment.