consequently use emplace back instead of push
This commit is contained in:
parent
9587923e55
commit
50594febc7
@ -75,8 +75,8 @@ void DescriptionFactory::SetEndSegment(const PhantomNode &target,
|
|||||||
const bool target_traversed_in_reverse)
|
const bool target_traversed_in_reverse)
|
||||||
{
|
{
|
||||||
target_phantom = target;
|
target_phantom = target;
|
||||||
path_description.push_back(
|
path_description.emplace_back(
|
||||||
SegmentInformation(target.location, target.name_id, 0, target.reverse_weight, 0, true));
|
target.location, target.name_id, 0, target.reverse_weight, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate,
|
void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate,
|
||||||
@ -88,11 +88,11 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path_description.push_back(SegmentInformation(coordinate,
|
path_description.emplace_back(coordinate,
|
||||||
path_point.name_id,
|
path_point.name_id,
|
||||||
path_point.segment_duration,
|
path_point.segment_duration,
|
||||||
0,
|
0,
|
||||||
path_point.turn_instruction));
|
path_point.turn_instruction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,21 +108,21 @@ void DescriptionFactory::AppendEncodedPolylineString(const bool return_encoded,
|
|||||||
{
|
{
|
||||||
polyline_compressor.printUnencodedString(path_description, temp);
|
polyline_compressor.printUnencodedString(path_description, temp);
|
||||||
}
|
}
|
||||||
output.push_back(temp);
|
output.emplace_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionFactory::AppendEncodedPolylineString(std::vector<std::string> &output) const
|
void DescriptionFactory::AppendEncodedPolylineString(std::vector<std::string> &output) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
polyline_compressor.printEncodedString(path_description, temp);
|
polyline_compressor.printEncodedString(path_description, temp);
|
||||||
output.push_back(temp);
|
output.emplace_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionFactory::AppendUnencodedPolylineString(std::vector<std::string> &output) const
|
void DescriptionFactory::AppendUnencodedPolylineString(std::vector<std::string> &output) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
polyline_compressor.printUnencodedString(path_description, temp);
|
polyline_compressor.printUnencodedString(path_description, temp);
|
||||||
output.push_back(temp);
|
output.emplace_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionFactory::BuildRouteSummary(const double distance, const unsigned time)
|
void DescriptionFactory::BuildRouteSummary(const double distance, const unsigned time)
|
||||||
|
@ -47,50 +47,51 @@ template <class DataFacadeT> class GPXDescriptor : public BaseDescriptor<DataFac
|
|||||||
DataFacadeT *facade,
|
DataFacadeT *facade,
|
||||||
http::Reply &reply)
|
http::Reply &reply)
|
||||||
{
|
{
|
||||||
reply.content.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
reply.content.emplace_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
reply.content.push_back("<gpx creator=\"OSRM Routing Engine\" version=\"1.1\" "
|
reply.content.emplace_back("<gpx creator=\"OSRM Routing Engine\" version=\"1.1\" "
|
||||||
"xmlns=\"http://www.topografix.com/GPX/1/1\" "
|
"xmlns=\"http://www.topografix.com/GPX/1/1\" "
|
||||||
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
||||||
"xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 gpx.xsd"
|
"xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 gpx.xsd"
|
||||||
"\">");
|
"\">");
|
||||||
reply.content.push_back("<metadata><copyright author=\"Project OSRM\"><license>Data (c)"
|
reply.content.emplace_back("<metadata><copyright author=\"Project OSRM\"><license>Data (c)"
|
||||||
" OpenStreetMap contributors (ODbL)</license></copyright>"
|
" OpenStreetMap contributors (ODbL)</license></copyright>"
|
||||||
"</metadata>");
|
"</metadata>");
|
||||||
reply.content.push_back("<rte>");
|
reply.content.emplace_back("<rte>");
|
||||||
bool found_route = (raw_route.shortest_path_length != INVALID_EDGE_WEIGHT) &&
|
bool found_route = (raw_route.shortest_path_length != INVALID_EDGE_WEIGHT) &&
|
||||||
(!raw_route.unpacked_path_segments.front().empty());
|
(!raw_route.unpacked_path_segments.front().empty());
|
||||||
if (found_route)
|
if (found_route)
|
||||||
{
|
{
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(
|
FixedPointCoordinate::convertInternalLatLonToString(
|
||||||
phantom_node_list.source_phantom.location.lat, tmp);
|
phantom_node_list.source_phantom.location.lat, tmp);
|
||||||
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
reply.content.emplace_back("<rtept lat=\"" + tmp + "\" ");
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(
|
FixedPointCoordinate::convertInternalLatLonToString(
|
||||||
phantom_node_list.source_phantom.location.lon, tmp);
|
phantom_node_list.source_phantom.location.lon, tmp);
|
||||||
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
reply.content.emplace_back("lon=\"" + tmp + "\"></rtept>");
|
||||||
|
|
||||||
for (const std::vector<PathData> &path_data_vector : raw_route.unpacked_path_segments)
|
for (const std::vector<PathData> &path_data_vector : raw_route.unpacked_path_segments)
|
||||||
{
|
{
|
||||||
for (const PathData &path_data : path_data_vector)
|
for (const PathData &path_data : path_data_vector)
|
||||||
{
|
{
|
||||||
FixedPointCoordinate current_coordinate = facade->GetCoordinateOfNode(path_data.node);
|
FixedPointCoordinate current_coordinate =
|
||||||
|
facade->GetCoordinateOfNode(path_data.node);
|
||||||
|
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(current_coordinate.lat,
|
FixedPointCoordinate::convertInternalLatLonToString(current_coordinate.lat,
|
||||||
tmp);
|
tmp);
|
||||||
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
reply.content.emplace_back("<rtept lat=\"" + tmp + "\" ");
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(current_coordinate.lon,
|
FixedPointCoordinate::convertInternalLatLonToString(current_coordinate.lon,
|
||||||
tmp);
|
tmp);
|
||||||
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
reply.content.emplace_back("lon=\"" + tmp + "\"></rtept>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add the via point or the end coordinate
|
// Add the via point or the end coordinate
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(
|
FixedPointCoordinate::convertInternalLatLonToString(
|
||||||
phantom_node_list.target_phantom.location.lat, tmp);
|
phantom_node_list.target_phantom.location.lat, tmp);
|
||||||
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
reply.content.emplace_back("<rtept lat=\"" + tmp + "\" ");
|
||||||
FixedPointCoordinate::convertInternalLatLonToString(
|
FixedPointCoordinate::convertInternalLatLonToString(
|
||||||
phantom_node_list.target_phantom.location.lon, tmp);
|
phantom_node_list.target_phantom.location.lon, tmp);
|
||||||
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
reply.content.emplace_back("lon=\"" + tmp + "\"></rtept>");
|
||||||
}
|
}
|
||||||
reply.content.push_back("</rte></gpx>");
|
reply.content.emplace_back("</rte></gpx>");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif // GPX_DESCRIPTOR_H
|
#endif // GPX_DESCRIPTOR_H
|
||||||
|
@ -78,8 +78,8 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
public:
|
public:
|
||||||
JSONDescriptor() : facade(nullptr), entered_restricted_area_count(0)
|
JSONDescriptor() : facade(nullptr), entered_restricted_area_count(0)
|
||||||
{
|
{
|
||||||
shortest_leg_end_indices.push_back(0);
|
shortest_leg_end_indices.emplace_back(0);
|
||||||
alternative_leg_end_indices.push_back(0);
|
alternative_leg_end_indices.emplace_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetConfig(const DescriptorConfig &c) { config = c; }
|
void SetConfig(const DescriptorConfig &c) { config = c; }
|
||||||
@ -108,12 +108,12 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
http::Reply &reply)
|
http::Reply &reply)
|
||||||
{
|
{
|
||||||
facade = f;
|
facade = f;
|
||||||
reply.content.push_back("{\"status\":");
|
reply.content.emplace_back("{\"status\":");
|
||||||
|
|
||||||
if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length)
|
if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length)
|
||||||
{
|
{
|
||||||
// We do not need to do much, if there is no route ;-)
|
// We do not need to do much, if there is no route ;-)
|
||||||
reply.content.push_back(
|
reply.content.emplace_back(
|
||||||
"207,\"status_message\": \"Cannot find route between points\"}");
|
"207,\"status_message\": \"Cannot find route between points\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
|
|
||||||
description_factory.SetStartSegment(phantom_nodes.source_phantom,
|
description_factory.SetStartSegment(phantom_nodes.source_phantom,
|
||||||
raw_route.source_traversed_in_reverse);
|
raw_route.source_traversed_in_reverse);
|
||||||
reply.content.push_back("0,"
|
reply.content.emplace_back("0,"
|
||||||
"\"status_message\": \"Found route between points\",");
|
"\"status_message\": \"Found route between points\",");
|
||||||
|
|
||||||
// for each unpacked segment add the leg to the description
|
// for each unpacked segment add the leg to the description
|
||||||
@ -138,23 +138,23 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
const int added_segments = DescribeLeg(raw_route.unpacked_path_segments[i],
|
const int added_segments = DescribeLeg(raw_route.unpacked_path_segments[i],
|
||||||
raw_route.segment_end_coordinates[i]);
|
raw_route.segment_end_coordinates[i]);
|
||||||
BOOST_ASSERT(0 < added_segments);
|
BOOST_ASSERT(0 < added_segments);
|
||||||
shortest_leg_end_indices.push_back(added_segments + shortest_leg_end_indices.back());
|
shortest_leg_end_indices.emplace_back(added_segments + shortest_leg_end_indices.back());
|
||||||
}
|
}
|
||||||
description_factory.SetEndSegment(phantom_nodes.target_phantom,
|
description_factory.SetEndSegment(phantom_nodes.target_phantom,
|
||||||
raw_route.target_traversed_in_reverse);
|
raw_route.target_traversed_in_reverse);
|
||||||
description_factory.Run(facade, config.zoom_level);
|
description_factory.Run(facade, config.zoom_level);
|
||||||
|
|
||||||
reply.content.push_back("\"route_geometry\": ");
|
reply.content.emplace_back("\"route_geometry\": ");
|
||||||
if (config.geometry)
|
if (config.geometry)
|
||||||
{
|
{
|
||||||
description_factory.AppendEncodedPolylineString(config.encode_geometry, reply.content);
|
description_factory.AppendEncodedPolylineString(config.encode_geometry, reply.content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reply.content.push_back("[]");
|
reply.content.emplace_back("[]");
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.content.push_back(",\"route_instructions\": [");
|
reply.content.emplace_back(",\"route_instructions\": [");
|
||||||
if (config.instructions)
|
if (config.instructions)
|
||||||
{
|
{
|
||||||
BuildTextualDescription(description_factory,
|
BuildTextualDescription(description_factory,
|
||||||
@ -163,28 +163,28 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
facade,
|
facade,
|
||||||
shortest_path_segments);
|
shortest_path_segments);
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
description_factory.BuildRouteSummary(description_factory.entireLength,
|
description_factory.BuildRouteSummary(description_factory.entireLength,
|
||||||
raw_route.shortest_path_length);
|
raw_route.shortest_path_length);
|
||||||
|
|
||||||
reply.content.push_back("\"route_summary\":");
|
reply.content.emplace_back("\"route_summary\":");
|
||||||
reply.content.push_back("{");
|
reply.content.emplace_back("{");
|
||||||
reply.content.push_back("\"total_distance\":");
|
reply.content.emplace_back("\"total_distance\":");
|
||||||
reply.content.push_back(description_factory.summary.lengthString);
|
reply.content.emplace_back(description_factory.summary.lengthString);
|
||||||
reply.content.push_back(","
|
reply.content.emplace_back(","
|
||||||
"\"total_time\":");
|
"\"total_time\":");
|
||||||
reply.content.push_back(description_factory.summary.durationString);
|
reply.content.emplace_back(description_factory.summary.durationString);
|
||||||
reply.content.push_back(","
|
reply.content.emplace_back(","
|
||||||
"\"start_point\":\"");
|
"\"start_point\":\"");
|
||||||
reply.content.push_back(
|
reply.content.emplace_back(
|
||||||
facade->GetEscapedNameForNameID(description_factory.summary.startName));
|
facade->GetEscapedNameForNameID(description_factory.summary.startName));
|
||||||
reply.content.push_back("\","
|
reply.content.emplace_back("\","
|
||||||
"\"end_point\":\"");
|
"\"end_point\":\"");
|
||||||
reply.content.push_back(
|
reply.content.emplace_back(
|
||||||
facade->GetEscapedNameForNameID(description_factory.summary.destName));
|
facade->GetEscapedNameForNameID(description_factory.summary.destName));
|
||||||
reply.content.push_back("\"");
|
reply.content.emplace_back("\"");
|
||||||
reply.content.push_back("}");
|
reply.content.emplace_back("}");
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
|
|
||||||
// only one alternative route is computed at this time, so this is hardcoded
|
// only one alternative route is computed at this time, so this is hardcoded
|
||||||
if (raw_route.alternative_path_length != INVALID_EDGE_WEIGHT)
|
if (raw_route.alternative_path_length != INVALID_EDGE_WEIGHT)
|
||||||
@ -203,18 +203,18 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
alternate_descriptionFactory.Run(facade, config.zoom_level);
|
alternate_descriptionFactory.Run(facade, config.zoom_level);
|
||||||
|
|
||||||
// //give an array of alternative routes
|
// //give an array of alternative routes
|
||||||
reply.content.push_back("\"alternative_geometries\": [");
|
reply.content.emplace_back("\"alternative_geometries\": [");
|
||||||
if (config.geometry && INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
if (config.geometry && INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
||||||
{
|
{
|
||||||
// Generate the linestrings for each alternative
|
// Generate the linestrings for each alternative
|
||||||
alternate_descriptionFactory.AppendEncodedPolylineString(config.encode_geometry,
|
alternate_descriptionFactory.AppendEncodedPolylineString(config.encode_geometry,
|
||||||
reply.content);
|
reply.content);
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
reply.content.push_back("\"alternative_instructions\":[");
|
reply.content.emplace_back("\"alternative_instructions\":[");
|
||||||
if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
||||||
{
|
{
|
||||||
reply.content.push_back("[");
|
reply.content.emplace_back("[");
|
||||||
// Generate instructions for each alternative
|
// Generate instructions for each alternative
|
||||||
if (config.instructions)
|
if (config.instructions)
|
||||||
{
|
{
|
||||||
@ -224,113 +224,113 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
facade,
|
facade,
|
||||||
alternative_path_segments);
|
alternative_path_segments);
|
||||||
}
|
}
|
||||||
reply.content.push_back("]");
|
reply.content.emplace_back("]");
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
reply.content.push_back("\"alternative_summaries\":[");
|
reply.content.emplace_back("\"alternative_summaries\":[");
|
||||||
if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
||||||
{
|
{
|
||||||
// Generate route summary (length, duration) for each alternative
|
// Generate route summary (length, duration) for each alternative
|
||||||
alternate_descriptionFactory.BuildRouteSummary(
|
alternate_descriptionFactory.BuildRouteSummary(
|
||||||
alternate_descriptionFactory.entireLength, raw_route.alternative_path_length);
|
alternate_descriptionFactory.entireLength, raw_route.alternative_path_length);
|
||||||
reply.content.push_back("{");
|
reply.content.emplace_back("{");
|
||||||
reply.content.push_back("\"total_distance\":");
|
reply.content.emplace_back("\"total_distance\":");
|
||||||
reply.content.push_back(alternate_descriptionFactory.summary.lengthString);
|
reply.content.emplace_back(alternate_descriptionFactory.summary.lengthString);
|
||||||
reply.content.push_back(","
|
reply.content.emplace_back(","
|
||||||
"\"total_time\":");
|
"\"total_time\":");
|
||||||
reply.content.push_back(alternate_descriptionFactory.summary.durationString);
|
reply.content.emplace_back(alternate_descriptionFactory.summary.durationString);
|
||||||
reply.content.push_back(","
|
reply.content.emplace_back(","
|
||||||
"\"start_point\":\"");
|
"\"start_point\":\"");
|
||||||
reply.content.push_back(
|
reply.content.emplace_back(
|
||||||
facade->GetEscapedNameForNameID(description_factory.summary.startName));
|
facade->GetEscapedNameForNameID(description_factory.summary.startName));
|
||||||
reply.content.push_back("\","
|
reply.content.emplace_back("\","
|
||||||
"\"end_point\":\"");
|
"\"end_point\":\"");
|
||||||
reply.content.push_back(
|
reply.content.emplace_back(
|
||||||
facade->GetEscapedNameForNameID(description_factory.summary.destName));
|
facade->GetEscapedNameForNameID(description_factory.summary.destName));
|
||||||
reply.content.push_back("\"");
|
reply.content.emplace_back("\"");
|
||||||
reply.content.push_back("}");
|
reply.content.emplace_back("}");
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
|
|
||||||
// //Get Names for both routes
|
// //Get Names for both routes
|
||||||
RouteNames routeNames;
|
RouteNames routeNames;
|
||||||
GetRouteNames(shortest_path_segments, alternative_path_segments, facade, routeNames);
|
GetRouteNames(shortest_path_segments, alternative_path_segments, facade, routeNames);
|
||||||
|
|
||||||
reply.content.push_back("\"route_name\":[\"");
|
reply.content.emplace_back("\"route_name\":[\"");
|
||||||
reply.content.push_back(routeNames.shortest_path_name_1);
|
reply.content.emplace_back(routeNames.shortest_path_name_1);
|
||||||
reply.content.push_back("\",\"");
|
reply.content.emplace_back("\",\"");
|
||||||
reply.content.push_back(routeNames.shortest_path_name_2);
|
reply.content.emplace_back(routeNames.shortest_path_name_2);
|
||||||
reply.content.push_back("\"],"
|
reply.content.emplace_back("\"],"
|
||||||
"\"alternative_names\":[");
|
"\"alternative_names\":[");
|
||||||
reply.content.push_back("[\"");
|
reply.content.emplace_back("[\"");
|
||||||
reply.content.push_back(routeNames.alternative_path_name_1);
|
reply.content.emplace_back(routeNames.alternative_path_name_1);
|
||||||
reply.content.push_back("\",\"");
|
reply.content.emplace_back("\",\"");
|
||||||
reply.content.push_back(routeNames.alternative_path_name_2);
|
reply.content.emplace_back(routeNames.alternative_path_name_2);
|
||||||
reply.content.push_back("\"]");
|
reply.content.emplace_back("\"]");
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
// list all viapoints so that the client may display it
|
// list all viapoints so that the client may display it
|
||||||
reply.content.push_back("\"via_points\":[");
|
reply.content.emplace_back("\"via_points\":[");
|
||||||
|
|
||||||
BOOST_ASSERT(!raw_route.segment_end_coordinates.empty());
|
BOOST_ASSERT(!raw_route.segment_end_coordinates.empty());
|
||||||
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FixedPointCoordinate::convertInternalReversedCoordinateToString(
|
FixedPointCoordinate::convertInternalReversedCoordinateToString(
|
||||||
raw_route.segment_end_coordinates.front().source_phantom.location, tmp);
|
raw_route.segment_end_coordinates.front().source_phantom.location, tmp);
|
||||||
reply.content.push_back("[");
|
reply.content.emplace_back("[");
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
reply.content.push_back("]");
|
reply.content.emplace_back("]");
|
||||||
|
|
||||||
for (const PhantomNodes &nodes : raw_route.segment_end_coordinates)
|
for (const PhantomNodes &nodes : raw_route.segment_end_coordinates)
|
||||||
{
|
{
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
FixedPointCoordinate::convertInternalReversedCoordinateToString(
|
FixedPointCoordinate::convertInternalReversedCoordinateToString(
|
||||||
nodes.target_phantom.location, tmp);
|
nodes.target_phantom.location, tmp);
|
||||||
reply.content.push_back(",[");
|
reply.content.emplace_back(",[");
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
reply.content.push_back("]");
|
reply.content.emplace_back("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
reply.content.push_back("\"via_indices\":[");
|
reply.content.emplace_back("\"via_indices\":[");
|
||||||
for (const unsigned index : shortest_leg_end_indices)
|
for (const unsigned index : shortest_leg_end_indices)
|
||||||
{
|
{
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
intToString(index, tmp);
|
intToString(index, tmp);
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
if (index != shortest_leg_end_indices.back())
|
if (index != shortest_leg_end_indices.back())
|
||||||
{
|
{
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reply.content.push_back("],\"alternative_indices\":[");
|
reply.content.emplace_back("],\"alternative_indices\":[");
|
||||||
if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length)
|
||||||
{
|
{
|
||||||
reply.content.push_back("0,");
|
reply.content.emplace_back("0,");
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
intToString(alternate_descriptionFactory.path_description.size(), tmp);
|
intToString(alternate_descriptionFactory.path_description.size(), tmp);
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.content.push_back("],");
|
reply.content.emplace_back("],");
|
||||||
reply.content.push_back("\"hint_data\": {");
|
reply.content.emplace_back("\"hint_data\": {");
|
||||||
reply.content.push_back("\"checksum\":");
|
reply.content.emplace_back("\"checksum\":");
|
||||||
intToString(raw_route.check_sum, tmp);
|
intToString(raw_route.check_sum, tmp);
|
||||||
reply.content.push_back(tmp);
|
reply.content.emplace_back(tmp);
|
||||||
reply.content.push_back(", \"locations\": [");
|
reply.content.emplace_back(", \"locations\": [");
|
||||||
|
|
||||||
std::string hint;
|
std::string hint;
|
||||||
for (unsigned i = 0; i < raw_route.segment_end_coordinates.size(); ++i)
|
for (unsigned i = 0; i < raw_route.segment_end_coordinates.size(); ++i)
|
||||||
{
|
{
|
||||||
reply.content.push_back("\"");
|
reply.content.emplace_back("\"");
|
||||||
EncodeObjectToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
|
EncodeObjectToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
|
||||||
reply.content.push_back(hint);
|
reply.content.emplace_back(hint);
|
||||||
reply.content.push_back("\", ");
|
reply.content.emplace_back("\", ");
|
||||||
}
|
}
|
||||||
EncodeObjectToBase64(raw_route.segment_end_coordinates.back().target_phantom, hint);
|
EncodeObjectToBase64(raw_route.segment_end_coordinates.back().target_phantom, hint);
|
||||||
reply.content.push_back("\"");
|
reply.content.emplace_back("\"");
|
||||||
reply.content.push_back(hint);
|
reply.content.emplace_back(hint);
|
||||||
reply.content.push_back("\"]");
|
reply.content.emplace_back("\"]");
|
||||||
reply.content.push_back("}}");
|
reply.content.emplace_back("}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct routes names
|
// construct routes names
|
||||||
@ -349,9 +349,8 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
|
|
||||||
if (!shortest_path_segments.empty())
|
if (!shortest_path_segments.empty())
|
||||||
{
|
{
|
||||||
std::sort(shortest_path_segments.begin(),
|
std::sort(
|
||||||
shortest_path_segments.end(),
|
shortest_path_segments.begin(), shortest_path_segments.end(), length_comperator);
|
||||||
length_comperator);
|
|
||||||
shortest_segment_1 = shortest_path_segments[0];
|
shortest_segment_1 = shortest_path_segments[0];
|
||||||
if (!alternative_path_segments.empty())
|
if (!alternative_path_segments.empty())
|
||||||
{
|
{
|
||||||
@ -453,47 +452,47 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
{
|
{
|
||||||
if (necessary_segments_running_index)
|
if (necessary_segments_running_index)
|
||||||
{
|
{
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
}
|
}
|
||||||
reply.content.push_back("[\"");
|
reply.content.emplace_back("[\"");
|
||||||
if (TurnInstructionsClass::LeaveRoundAbout == current_instruction)
|
if (TurnInstructionsClass::LeaveRoundAbout == current_instruction)
|
||||||
{
|
{
|
||||||
intToString(TurnInstructionsClass::EnterRoundAbout, temp_instruction);
|
intToString(TurnInstructionsClass::EnterRoundAbout, temp_instruction);
|
||||||
reply.content.push_back(temp_instruction);
|
reply.content.emplace_back(temp_instruction);
|
||||||
reply.content.push_back("-");
|
reply.content.emplace_back("-");
|
||||||
intToString(round_about.leave_at_exit + 1, temp_instruction);
|
intToString(round_about.leave_at_exit + 1, temp_instruction);
|
||||||
reply.content.push_back(temp_instruction);
|
reply.content.emplace_back(temp_instruction);
|
||||||
round_about.leave_at_exit = 0;
|
round_about.leave_at_exit = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
intToString(current_instruction, temp_instruction);
|
intToString(current_instruction, temp_instruction);
|
||||||
reply.content.push_back(temp_instruction);
|
reply.content.emplace_back(temp_instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.content.push_back("\",\"");
|
reply.content.emplace_back("\",\"");
|
||||||
reply.content.push_back(facade->GetEscapedNameForNameID(segment.name_id));
|
reply.content.emplace_back(facade->GetEscapedNameForNameID(segment.name_id));
|
||||||
reply.content.push_back("\",");
|
reply.content.emplace_back("\",");
|
||||||
intToString(segment.length, temp_dist);
|
intToString(segment.length, temp_dist);
|
||||||
reply.content.push_back(temp_dist);
|
reply.content.emplace_back(temp_dist);
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
intToString(necessary_segments_running_index, temp_length);
|
intToString(necessary_segments_running_index, temp_length);
|
||||||
reply.content.push_back(temp_length);
|
reply.content.emplace_back(temp_length);
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
intToString(round(segment.duration / 10.), temp_duration);
|
intToString(round(segment.duration / 10.), temp_duration);
|
||||||
reply.content.push_back(temp_duration);
|
reply.content.emplace_back(temp_duration);
|
||||||
reply.content.push_back(",\"");
|
reply.content.emplace_back(",\"");
|
||||||
intToString(segment.length, temp_length);
|
intToString(segment.length, temp_length);
|
||||||
reply.content.push_back(temp_length);
|
reply.content.emplace_back(temp_length);
|
||||||
reply.content.push_back("m\",\"");
|
reply.content.emplace_back("m\",\"");
|
||||||
int bearing_value = round(segment.bearing / 10.);
|
int bearing_value = round(segment.bearing / 10.);
|
||||||
reply.content.push_back(Azimuth::Get(bearing_value));
|
reply.content.emplace_back(Azimuth::Get(bearing_value));
|
||||||
reply.content.push_back("\",");
|
reply.content.emplace_back("\",");
|
||||||
intToString(bearing_value, temp_bearing);
|
intToString(bearing_value, temp_bearing);
|
||||||
reply.content.push_back(temp_bearing);
|
reply.content.emplace_back(temp_bearing);
|
||||||
reply.content.push_back("]");
|
reply.content.emplace_back("]");
|
||||||
|
|
||||||
route_segments_list.push_back(
|
route_segments_list.emplace_back(
|
||||||
Segment(segment.name_id, segment.length, route_segments_list.size()));
|
Segment(segment.name_id, segment.length, route_segments_list.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,23 +507,23 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
|
|||||||
}
|
}
|
||||||
if (INVALID_EDGE_WEIGHT != route_length)
|
if (INVALID_EDGE_WEIGHT != route_length)
|
||||||
{
|
{
|
||||||
reply.content.push_back(",[\"");
|
reply.content.emplace_back(",[\"");
|
||||||
intToString(TurnInstructionsClass::ReachedYourDestination, temp_instruction);
|
intToString(TurnInstructionsClass::ReachedYourDestination, temp_instruction);
|
||||||
reply.content.push_back(temp_instruction);
|
reply.content.emplace_back(temp_instruction);
|
||||||
reply.content.push_back("\",\"");
|
reply.content.emplace_back("\",\"");
|
||||||
reply.content.push_back("\",");
|
reply.content.emplace_back("\",");
|
||||||
reply.content.push_back("0");
|
reply.content.emplace_back("0");
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
intToString(necessary_segments_running_index - 1, temp_length);
|
intToString(necessary_segments_running_index - 1, temp_length);
|
||||||
reply.content.push_back(temp_length);
|
reply.content.emplace_back(temp_length);
|
||||||
reply.content.push_back(",");
|
reply.content.emplace_back(",");
|
||||||
reply.content.push_back("0");
|
reply.content.emplace_back("0");
|
||||||
reply.content.push_back(",\"");
|
reply.content.emplace_back(",\"");
|
||||||
reply.content.push_back("\",\"");
|
reply.content.emplace_back("\",\"");
|
||||||
reply.content.push_back(Azimuth::Get(0.0));
|
reply.content.emplace_back(Azimuth::Get(0.0));
|
||||||
reply.content.push_back("\",");
|
reply.content.emplace_back("\",");
|
||||||
reply.content.push_back("0.0");
|
reply.content.emplace_back("0.0");
|
||||||
reply.content.push_back("]");
|
reply.content.emplace_back("]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user