Only run step collapsing based on original waypoints parameter (#4829)

This commit is contained in:
Karen Shea
2018-01-29 12:35:55 -08:00
committed by GitHub
parent 77f8a4f741
commit c154875272
4 changed files with 32 additions and 1 deletions
+5 -1
View File
@@ -247,6 +247,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
}
// Error: Check if user-supplied waypoints can be found in the resulting matches
if (!parameters.waypoints.empty())
{
std::set<std::size_t> tidied_waypoints(tidied.parameters.waypoints.begin(),
tidied.parameters.waypoints.end());
@@ -262,6 +263,9 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
"NoMatch", "Requested waypoint parameter could not be matched.", json_result);
}
}
// we haven't errored yet, only allow leg collapsing if it was originally requested
BOOST_ASSERT(parameters.waypoints.empty() || sub_matchings.size() == 1);
const auto collapse_legs = !parameters.waypoints.empty();
// each sub_route will correspond to a MatchObject
std::vector<InternalRouteResult> sub_routes(sub_matchings.size());
@@ -286,7 +290,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
sub_routes[index] =
algorithms.ShortestPathSearch(sub_routes[index].segment_end_coordinates, {false});
BOOST_ASSERT(sub_routes[index].shortest_path_weight != INVALID_EDGE_WEIGHT);
if (!tidied.parameters.waypoints.empty())
if (collapse_legs)
{
std::vector<bool> waypoint_legs;
waypoint_legs.reserve(sub_matchings[index].indices.size());