@@ -110,14 +110,14 @@ class RouteAPI : public BaseAPI
110110
111111 if (!parameters.skip_waypoints )
112112 {
113- response.values [ " waypoints" ] = BaseAPI::MakeWaypoints (waypoint_candidates);
113+ response.values . emplace ( " waypoints" , BaseAPI::MakeWaypoints (waypoint_candidates) );
114114 }
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" ) ;
117117 auto data_timestamp = facade.GetTimestamp ();
118118 if (!data_timestamp.empty ())
119119 {
120- response.values [ " data_version" ] = data_timestamp;
120+ response.values . emplace ( " data_version" , data_timestamp) ;
121121 }
122122 }
123123
@@ -784,49 +784,57 @@ class RouteAPI : public BaseAPI
784784 if (requested_annotations & RouteParameters::AnnotationsType::Speed)
785785 {
786786 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+ }));
802805 }
803806
804807 if (requested_annotations & RouteParameters::AnnotationsType::Duration)
805808 {
806- annotation.values [" duration" ] =
809+ annotation.values .emplace (
810+ " duration" ,
807811 GetAnnotations (leg_geometry,
808812 [](const guidance::LegGeometry::Annotation &anno)
809- { return anno.duration ; });
813+ { return anno.duration ; })) ;
810814 }
811815 if (requested_annotations & RouteParameters::AnnotationsType::Distance)
812816 {
813- annotation.values [" distance" ] =
817+ annotation.values .emplace (
818+ " distance" ,
814819 GetAnnotations (leg_geometry,
815820 [](const guidance::LegGeometry::Annotation &anno)
816- { return anno.distance ; });
821+ { return anno.distance ; })) ;
817822 }
818823 if (requested_annotations & RouteParameters::AnnotationsType::Weight)
819824 {
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 ; }));
823830 }
824831 if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
825832 {
826- annotation.values [" datasources" ] =
833+ annotation.values .emplace (
834+ " datasources" ,
827835 GetAnnotations (leg_geometry,
828836 [](const guidance::LegGeometry::Annotation &anno)
829- { return anno.datasource ; });
837+ { return anno.datasource ; })) ;
830838 }
831839 if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
832840 {
@@ -837,7 +845,7 @@ class RouteAPI : public BaseAPI
837845 nodes.values .push_back (
838846 static_cast <std::uint64_t >(facade.GetOSMNodeIDOfNode (node_id)));
839847 }
840- annotation.values [ " nodes" ] = std::move (nodes);
848+ annotation.values . emplace ( " nodes" , std::move (nodes) );
841849 }
842850 // Add any supporting metadata, if needed
843851 if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
@@ -853,8 +861,8 @@ class RouteAPI : public BaseAPI
853861 break ;
854862 datasource_names.values .push_back (std::string (facade.GetDatasourceName (i)));
855863 }
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) ;
858866 }
859867
860868 annotations.push_back (std::move (annotation));
0 commit comments