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