@@ -110,14 +110,14 @@ class RouteAPI : public BaseAPI
110
110
111
111
if (!parameters.skip_waypoints )
112
112
{
113
- response.values [ " waypoints" ] = BaseAPI::MakeWaypoints (waypoint_candidates);
113
+ response.values . emplace ( " waypoints" , BaseAPI::MakeWaypoints (waypoint_candidates) );
114
114
}
115
- response.values [ " routes" ] = std::move (jsRoutes);
116
- response.values [ " code" ] = " Ok" ;
115
+ response.values . emplace ( " routes" , std::move (jsRoutes) );
116
+ response.values . emplace ( " code" , " Ok" ) ;
117
117
auto data_timestamp = facade.GetTimestamp ();
118
118
if (!data_timestamp.empty ())
119
119
{
120
- response.values [ " data_version" ] = data_timestamp;
120
+ response.values . emplace ( " data_version" , data_timestamp) ;
121
121
}
122
122
}
123
123
@@ -784,49 +784,57 @@ class RouteAPI : public BaseAPI
784
784
if (requested_annotations & RouteParameters::AnnotationsType::Speed)
785
785
{
786
786
double prev_speed = 0 ;
787
- annotation.values [" speed" ] = GetAnnotations (
788
- leg_geometry,
789
- [&prev_speed](const guidance::LegGeometry::Annotation &anno)
790
- {
791
- if (anno.duration < std::numeric_limits<double >::min ())
792
- {
793
- return prev_speed;
794
- }
795
- else
796
- {
797
- auto speed = std::round (anno.distance / anno.duration * 10 .) / 10 .;
798
- prev_speed = speed;
799
- return util::json::clamp_float (speed);
800
- }
801
- });
787
+ annotation.values .emplace (
788
+ " speed" ,
789
+ GetAnnotations (leg_geometry,
790
+ [&prev_speed](const guidance::LegGeometry::Annotation &anno)
791
+ {
792
+ if (anno.duration < std::numeric_limits<double >::min ())
793
+ {
794
+ return prev_speed;
795
+ }
796
+ else
797
+ {
798
+ auto speed =
799
+ std::round (anno.distance / anno.duration * 10 .) /
800
+ 10 .;
801
+ prev_speed = speed;
802
+ return util::json::clamp_float (speed);
803
+ }
804
+ }));
802
805
}
803
806
804
807
if (requested_annotations & RouteParameters::AnnotationsType::Duration)
805
808
{
806
- annotation.values [" duration" ] =
809
+ annotation.values .emplace (
810
+ " duration" ,
807
811
GetAnnotations (leg_geometry,
808
812
[](const guidance::LegGeometry::Annotation &anno)
809
- { return anno.duration ; });
813
+ { return anno.duration ; })) ;
810
814
}
811
815
if (requested_annotations & RouteParameters::AnnotationsType::Distance)
812
816
{
813
- annotation.values [" distance" ] =
817
+ annotation.values .emplace (
818
+ " distance" ,
814
819
GetAnnotations (leg_geometry,
815
820
[](const guidance::LegGeometry::Annotation &anno)
816
- { return anno.distance ; });
821
+ { return anno.distance ; })) ;
817
822
}
818
823
if (requested_annotations & RouteParameters::AnnotationsType::Weight)
819
824
{
820
- annotation.values [" weight" ] = GetAnnotations (
821
- leg_geometry,
822
- [](const guidance::LegGeometry::Annotation &anno) { return anno.weight ; });
825
+ annotation.values .emplace (
826
+ " weight" ,
827
+ GetAnnotations (leg_geometry,
828
+ [](const guidance::LegGeometry::Annotation &anno)
829
+ { return anno.weight ; }));
823
830
}
824
831
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
825
832
{
826
- annotation.values [" datasources" ] =
833
+ annotation.values .emplace (
834
+ " datasources" ,
827
835
GetAnnotations (leg_geometry,
828
836
[](const guidance::LegGeometry::Annotation &anno)
829
- { return anno.datasource ; });
837
+ { return anno.datasource ; })) ;
830
838
}
831
839
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
832
840
{
@@ -837,7 +845,7 @@ class RouteAPI : public BaseAPI
837
845
nodes.values .push_back (
838
846
static_cast <std::uint64_t >(facade.GetOSMNodeIDOfNode (node_id)));
839
847
}
840
- annotation.values [ " nodes" ] = std::move (nodes);
848
+ annotation.values . emplace ( " nodes" , std::move (nodes) );
841
849
}
842
850
// Add any supporting metadata, if needed
843
851
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
@@ -853,8 +861,8 @@ class RouteAPI : public BaseAPI
853
861
break ;
854
862
datasource_names.values .push_back (std::string (facade.GetDatasourceName (i)));
855
863
}
856
- metadata.values [ " datasource_names" ] = datasource_names;
857
- annotation.values [ " metadata" ] = metadata;
864
+ metadata.values . emplace ( " datasource_names" , datasource_names) ;
865
+ annotation.values . emplace ( " metadata" , metadata) ;
858
866
}
859
867
860
868
annotations.push_back (std::move (annotation));
0 commit comments