Don't pass down unsnapped coordinates. All information is already there
This commit is contained in:
		
							parent
							
								
									f36037ebf2
								
							
						
					
					
						commit
						5e5f72ae57
					
				| @ -39,7 +39,7 @@ class MatchAPI final : public RouteAPI | |||||||
|             auto route = MakeRoute(sub_routes[index].segment_end_coordinates, |             auto route = MakeRoute(sub_routes[index].segment_end_coordinates, | ||||||
|                                    sub_routes[index].unpacked_path_segments, |                                    sub_routes[index].unpacked_path_segments, | ||||||
|                                    sub_routes[index].source_traversed_in_reverse, |                                    sub_routes[index].source_traversed_in_reverse, | ||||||
|                                    sub_routes[index].target_traversed_in_reverse, nullptr); |                                    sub_routes[index].target_traversed_in_reverse); | ||||||
|             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)); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -37,23 +37,21 @@ class RouteAPI : public BaseAPI | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void MakeResponse(const InternalRouteResult &raw_route, |     void MakeResponse(const InternalRouteResult &raw_route, | ||||||
|                       util::json::Object &response, |                       util::json::Object &response) const | ||||||
|                       const std::vector<util::Coordinate> *const locations) const |  | ||||||
|     { |     { | ||||||
|         auto number_of_routes = raw_route.has_alternative() ? 2UL : 1UL; |         auto number_of_routes = raw_route.has_alternative() ? 2UL : 1UL; | ||||||
|         util::json::Array routes; |         util::json::Array routes; | ||||||
|         routes.values.resize(number_of_routes); |         routes.values.resize(number_of_routes); | ||||||
|         routes.values[0] = |         routes.values[0] = | ||||||
|             MakeRoute(raw_route.segment_end_coordinates, raw_route.unpacked_path_segments, |             MakeRoute(raw_route.segment_end_coordinates, raw_route.unpacked_path_segments, | ||||||
|                       raw_route.source_traversed_in_reverse, raw_route.target_traversed_in_reverse, |                       raw_route.source_traversed_in_reverse, raw_route.target_traversed_in_reverse); | ||||||
|                       locations); |  | ||||||
|         if (raw_route.has_alternative()) |         if (raw_route.has_alternative()) | ||||||
|         { |         { | ||||||
|             std::vector<std::vector<PathData>> wrapped_leg(1); |             std::vector<std::vector<PathData>> wrapped_leg(1); | ||||||
|             wrapped_leg.front() = std::move(raw_route.unpacked_alternative); |             wrapped_leg.front() = std::move(raw_route.unpacked_alternative); | ||||||
|             routes.values[1] = MakeRoute(raw_route.segment_end_coordinates, wrapped_leg, |             routes.values[1] = MakeRoute(raw_route.segment_end_coordinates, wrapped_leg, | ||||||
|                                          raw_route.alt_source_traversed_in_reverse, |                                          raw_route.alt_source_traversed_in_reverse, | ||||||
|                                          raw_route.alt_target_traversed_in_reverse, locations); |                                          raw_route.alt_target_traversed_in_reverse); | ||||||
|         } |         } | ||||||
|         response.values["waypoints"] = BaseAPI::MakeWaypoints(raw_route.segment_end_coordinates); |         response.values["waypoints"] = BaseAPI::MakeWaypoints(raw_route.segment_end_coordinates); | ||||||
|         response.values["routes"] = std::move(routes); |         response.values["routes"] = std::move(routes); | ||||||
| @ -76,8 +74,7 @@ class RouteAPI : public BaseAPI | |||||||
|     util::json::Object MakeRoute(const std::vector<PhantomNodes> &segment_end_coordinates, |     util::json::Object MakeRoute(const std::vector<PhantomNodes> &segment_end_coordinates, | ||||||
|                                  std::vector<std::vector<PathData>> unpacked_path_segments, |                                  std::vector<std::vector<PathData>> unpacked_path_segments, | ||||||
|                                  const std::vector<bool> &source_traversed_in_reverse, |                                  const std::vector<bool> &source_traversed_in_reverse, | ||||||
|                                  const std::vector<bool> &target_traversed_in_reverse, |                                  const std::vector<bool> &target_traversed_in_reverse) const | ||||||
|                                  const std::vector<util::Coordinate> *const locations) const |  | ||||||
|     { |     { | ||||||
|         std::vector<guidance::RouteLeg> legs; |         std::vector<guidance::RouteLeg> legs; | ||||||
|         std::vector<guidance::LegGeometry> leg_geometries; |         std::vector<guidance::LegGeometry> leg_geometries; | ||||||
| @ -102,17 +99,9 @@ class RouteAPI : public BaseAPI | |||||||
| 
 | 
 | ||||||
|             if (parameters.steps) |             if (parameters.steps) | ||||||
|             { |             { | ||||||
|                 const auto getLoc = [](const std::vector<util::Coordinate> *const locations, |  | ||||||
|                                        int idx) -> boost::optional<util::Coordinate> |  | ||||||
|                 { |  | ||||||
|                     if (locations) |  | ||||||
|                         return (*locations)[idx]; |  | ||||||
|                     return {}; |  | ||||||
|                 }; |  | ||||||
|                 leg.steps = guidance::assembleSteps( |                 leg.steps = guidance::assembleSteps( | ||||||
|                     BaseAPI::facade, path_data, leg_geometry, phantoms.source_phantom, |                     BaseAPI::facade, path_data, leg_geometry, phantoms.source_phantom, | ||||||
|                     phantoms.target_phantom, reversed_source, reversed_target, |                     phantoms.target_phantom, reversed_source, reversed_target); | ||||||
|                     getLoc(locations, idx), getLoc(locations, idx + 1)); |  | ||||||
|                 ; |                 ; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -28,8 +28,7 @@ class TripAPI final : public RouteAPI | |||||||
|     void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips, |     void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips, | ||||||
|                       const std::vector<InternalRouteResult> &sub_routes, |                       const std::vector<InternalRouteResult> &sub_routes, | ||||||
|                       const std::vector<PhantomNode> &phantoms, |                       const std::vector<PhantomNode> &phantoms, | ||||||
|                       util::json::Object &response, |                       util::json::Object &response) const | ||||||
|                       const std::vector<std::vector<util::Coordinate>> &coordinates) const |  | ||||||
|     { |     { | ||||||
|         auto number_of_routes = sub_trips.size(); |         auto number_of_routes = sub_trips.size(); | ||||||
|         util::json::Array routes; |         util::json::Array routes; | ||||||
| @ -40,7 +39,7 @@ class TripAPI final : public RouteAPI | |||||||
|             auto route = MakeRoute( |             auto route = MakeRoute( | ||||||
|                 sub_routes[index].segment_end_coordinates, sub_routes[index].unpacked_path_segments, |                 sub_routes[index].segment_end_coordinates, sub_routes[index].unpacked_path_segments, | ||||||
|                 sub_routes[index].source_traversed_in_reverse, |                 sub_routes[index].source_traversed_in_reverse, | ||||||
|                 sub_routes[index].target_traversed_in_reverse, &coordinates[index]); |                 sub_routes[index].target_traversed_in_reverse); | ||||||
|             routes.values.push_back(std::move(route)); |             routes.values.push_back(std::move(route)); | ||||||
|         } |         } | ||||||
|         response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms); |         response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms); | ||||||
|  | |||||||
| @ -37,9 +37,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade, | |||||||
|                                      const PhantomNode &source_node, |                                      const PhantomNode &source_node, | ||||||
|                                      const PhantomNode &target_node, |                                      const PhantomNode &target_node, | ||||||
|                                      const bool source_traversed_in_reverse, |                                      const bool source_traversed_in_reverse, | ||||||
|                                      const bool target_traversed_in_reverse, |                                      const bool target_traversed_in_reverse) | ||||||
|                                      boost::optional<util::Coordinate> source_location, |  | ||||||
|                                      boost::optional<util::Coordinate> target_location) |  | ||||||
| { | { | ||||||
|     const auto source_duration = |     const auto source_duration = | ||||||
|         (source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset() |         (source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset() | ||||||
| @ -62,10 +60,11 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade, | |||||||
| 
 | 
 | ||||||
|     std::size_t segment_index = 0; |     std::size_t segment_index = 0; | ||||||
|     const auto initial_modifier = |     const auto initial_modifier = | ||||||
|         (source_location && leg_geometry.locations.size() >= 2) |         leg_geometry.locations.size() >= 3 | ||||||
|             ? angleToDirectionModifier(util::coordinate_calculation::computeAngle( |             ? angleToDirectionModifier(util::coordinate_calculation::computeAngle( | ||||||
|                   source_location.get(), *(leg_geometry.locations.begin()), |                   leg_geometry.locations[0], | ||||||
|                   *(leg_geometry.locations.begin() + 1))) |                   leg_geometry.locations[1], | ||||||
|  |                   leg_geometry.locations[2])) | ||||||
|             : extractor::guidance::DirectionModifier::UTurn; |             : extractor::guidance::DirectionModifier::UTurn; | ||||||
| 
 | 
 | ||||||
|     if (leg_data.size() > 0) |     if (leg_data.size() > 0) | ||||||
| @ -122,10 +121,11 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade, | |||||||
| 
 | 
 | ||||||
|     BOOST_ASSERT(segment_index == number_of_segments - 1); |     BOOST_ASSERT(segment_index == number_of_segments - 1); | ||||||
|     const auto final_modifier = |     const auto final_modifier = | ||||||
|         (target_location && leg_geometry.locations.size() >= 2) |         leg_geometry.locations.size() >= 3 | ||||||
|             ? angleToDirectionModifier(util::coordinate_calculation::computeAngle( |             ? angleToDirectionModifier(util::coordinate_calculation::computeAngle( | ||||||
|                   *(leg_geometry.locations.end() - 2), *(leg_geometry.locations.end() - 1), |                   leg_geometry.locations[leg_geometry.locations.size() - 3], | ||||||
|                   target_location.get())) |                   leg_geometry.locations[leg_geometry.locations.size() - 2], | ||||||
|  |                   leg_geometry.locations[leg_geometry.locations.size() - 1])) | ||||||
|             : extractor::guidance::DirectionModifier::UTurn; |             : extractor::guidance::DirectionModifier::UTurn; | ||||||
|     // This step has length zero, the only reason we need it is the target location
 |     // This step has length zero, the only reason we need it is the target location
 | ||||||
|     steps.push_back(RouteStep{ |     steps.push_back(RouteStep{ | ||||||
|  | |||||||
| @ -243,18 +243,13 @@ Status TripPlugin::HandleRequest(const api::TripParameters ¶meters, | |||||||
|     // compute all round trip routes
 |     // compute all round trip routes
 | ||||||
|     std::vector<InternalRouteResult> routes; |     std::vector<InternalRouteResult> routes; | ||||||
|     routes.reserve(trips.size()); |     routes.reserve(trips.size()); | ||||||
|     std::vector<std::vector<util::Coordinate>> ordered_coordinates; |  | ||||||
|     ordered_coordinates.reserve(trips.size()); |  | ||||||
|     for (const auto &trip : trips) |     for (const auto &trip : trips) | ||||||
|     { |     { | ||||||
|         routes.push_back(ComputeRoute(snapped_phantoms, parameters, trip)); |         routes.push_back(ComputeRoute(snapped_phantoms, parameters, trip)); | ||||||
|         ordered_coordinates.push_back(std::vector<util::Coordinate>()); |  | ||||||
|         for (const auto nid : trip) |  | ||||||
|             ordered_coordinates.back().push_back(parameters.coordinates[nid]); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     api::TripAPI trip_api{BasePlugin::facade, parameters}; |     api::TripAPI trip_api{BasePlugin::facade, parameters}; | ||||||
|     trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result, ordered_coordinates); |     trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result); | ||||||
| 
 | 
 | ||||||
|     return Status::Ok; |     return Status::Ok; | ||||||
| } | } | ||||||
|  | |||||||
| @ -87,7 +87,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter | |||||||
|     if (raw_route.is_valid()) |     if (raw_route.is_valid()) | ||||||
|     { |     { | ||||||
|         api::RouteAPI route_api{BasePlugin::facade, route_parameters}; |         api::RouteAPI route_api{BasePlugin::facade, route_parameters}; | ||||||
|         route_api.MakeResponse(raw_route, json_result, &route_parameters.coordinates); |         route_api.MakeResponse(raw_route, json_result); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user