Formatted the sources
This commit is contained in:
parent
fa5567e669
commit
e97ec13064
@ -83,7 +83,8 @@ class MatchAPI final : public RouteAPI
|
||||
route.values["confidence"] = sub_matchings[index].confidence;
|
||||
routes.values.push_back(std::move(route));
|
||||
}
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["tracepoints"] = MakeTracepoints(sub_matchings);
|
||||
}
|
||||
response.values["matchings"] = std::move(routes);
|
||||
|
@ -55,24 +55,27 @@ class NearestAPI final : public BaseAPI
|
||||
data_version_string = fb_result.CreateString(data_timestamp);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> waypoints_vector;
|
||||
if (!parameters.skip_waypoints) {
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||
waypoints_vector;
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||
waypoints.resize(phantom_nodes.front().size());
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.begin(),
|
||||
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
std::transform(
|
||||
phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.begin(),
|
||||
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
|
||||
auto node_values = MakeNodes(phantom_node);
|
||||
fbresult::Uint64Pair nodes{node_values.first, node_values.second};
|
||||
auto node_values = MakeNodes(phantom_node);
|
||||
fbresult::Uint64Pair nodes{node_values.first, node_values.second};
|
||||
|
||||
auto waypoint = MakeWaypoint(fb_result, phantom_node);
|
||||
waypoint.add_nodes(&nodes);
|
||||
auto waypoint = MakeWaypoint(fb_result, phantom_node);
|
||||
waypoint.add_nodes(&nodes);
|
||||
|
||||
return waypoint.Finish();
|
||||
});
|
||||
return waypoint.Finish();
|
||||
});
|
||||
|
||||
waypoints_vector = fb_result.CreateVector(waypoints);
|
||||
}
|
||||
@ -89,7 +92,8 @@ class NearestAPI final : public BaseAPI
|
||||
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
||||
util::json::Object &response) const
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
util::json::Array waypoints;
|
||||
waypoints.values.resize(phantom_nodes.front().size());
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
|
@ -110,7 +110,8 @@ class RouteAPI : public BaseAPI
|
||||
route.target_traversed_in_reverse));
|
||||
}
|
||||
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["waypoints"] = BaseAPI::MakeWaypoints(all_start_end_points);
|
||||
}
|
||||
response.values["routes"] = std::move(jsRoutes);
|
||||
@ -143,8 +144,10 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
|
||||
auto routes_vector = fb_result.CreateVector(routes);
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> waypoints_vector;
|
||||
if (!parameters.skip_waypoints) {
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
|
||||
waypoints_vector;
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
waypoints_vector = getWaypoints();
|
||||
}
|
||||
|
||||
|
@ -84,14 +84,16 @@ class TableAPI final : public BaseAPI
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources;
|
||||
if (parameters.sources.empty())
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
sources = MakeWaypoints(fb_result, phantoms);
|
||||
}
|
||||
number_of_sources = phantoms.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
sources = MakeWaypoints(fb_result, phantoms, parameters.sources);
|
||||
}
|
||||
}
|
||||
@ -100,14 +102,16 @@ class TableAPI final : public BaseAPI
|
||||
destinations;
|
||||
if (parameters.destinations.empty())
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
destinations = MakeWaypoints(fb_result, phantoms);
|
||||
}
|
||||
number_of_destinations = phantoms.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations);
|
||||
}
|
||||
}
|
||||
@ -171,28 +175,32 @@ class TableAPI final : public BaseAPI
|
||||
// symmetric case
|
||||
if (parameters.sources.empty())
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["sources"] = MakeWaypoints(phantoms);
|
||||
}
|
||||
number_of_sources = phantoms.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["sources"] = MakeWaypoints(phantoms, parameters.sources);
|
||||
}
|
||||
}
|
||||
|
||||
if (parameters.destinations.empty())
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["destinations"] = MakeWaypoints(phantoms);
|
||||
}
|
||||
number_of_destinations = phantoms.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ class TripAPI final : public RouteAPI
|
||||
sub_routes[index].target_traversed_in_reverse);
|
||||
routes.values.push_back(std::move(route));
|
||||
}
|
||||
if (!parameters.skip_waypoints) {
|
||||
if (!parameters.skip_waypoints)
|
||||
{
|
||||
response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms);
|
||||
}
|
||||
response.values["trips"] = std::move(routes);
|
||||
|
@ -153,8 +153,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
|
||||
qi::bool_[ph::bind(&engine::api::BaseParameters::generate_hints, qi::_r1) = qi::_1];
|
||||
|
||||
skip_waypoints_rule =
|
||||
qi::lit("skip_waypoints=") >
|
||||
qi::bool_[ph::bind(&engine::api::BaseParameters::skip_waypoints, qi::_r1) = qi::_1];
|
||||
qi::lit("skip_waypoints=") >
|
||||
qi::bool_[ph::bind(&engine::api::BaseParameters::skip_waypoints, qi::_r1) = qi::_1];
|
||||
|
||||
bearings_rule =
|
||||
qi::lit("bearings=") >
|
||||
|
@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_fb_serialization_skip_waypoints)
|
||||
using namespace osrm;
|
||||
|
||||
NearestParameters params;
|
||||
params.skip_waypoints=true;
|
||||
params.skip_waypoints = true;
|
||||
params.coordinates.push_back(get_dummy_location());
|
||||
|
||||
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
|
||||
|
@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_no_waypoints)
|
||||
const auto &legs = route_object.values.at("legs").get<json::Array>().values;
|
||||
BOOST_CHECK(!legs.empty());
|
||||
|
||||
//The rest of legs contents is verified by test_route_same_coordinates
|
||||
// The rest of legs contents is verified by test_route_same_coordinates
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include "coordinates.hpp"
|
||||
#include "fixture.hpp"
|
||||
|
||||
#include <engine/api/flatbuffers/fbresult_generated.h>
|
||||
#include "osrm/trip_parameters.hpp"
|
||||
#include <engine/api/flatbuffers/fbresult_generated.h>
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user