diff --git a/descriptors/json_descriptor.hpp b/descriptors/json_descriptor.hpp index 16daac66e..a4344d9bb 100644 --- a/descriptors/json_descriptor.hpp +++ b/descriptors/json_descriptor.hpp @@ -103,8 +103,6 @@ template class JSONDescriptor final : public BaseDescriptor< if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length) { // We do not need to do much, if there is no route ;-) - json_result.values["status"] = 207; - json_result.values["status_message"] = "Cannot find route between points"; return; } @@ -115,8 +113,6 @@ template class JSONDescriptor final : public BaseDescriptor< description_factory.SetStartSegment( raw_route.segment_end_coordinates.front().source_phantom, raw_route.source_traversed_in_reverse.front()); - json_result.values["status"] = 0; - json_result.values["status_message"] = "Found route between points"; // for each unpacked segment add the leg to the description for (const auto i : osrm::irange(0, raw_route.unpacked_path_segments.size())) diff --git a/features/testbot/status.feature b/features/testbot/status.feature index 1adb1f76a..86d825921 100644 --- a/features/testbot/status.feature +++ b/features/testbot/status.feature @@ -32,8 +32,8 @@ Feature: Status messages | from | to | route | status | message | | a | b | ab | 200 | Found route between points | | c | d | cd | 200 | Found route between points | - | a | c | | 207 | Impossible route between points. | - | b | d | | 207 | Impossible route between points. | + | a | c | | 207 | Impossible route between points | + | b | d | | 207 | Impossible route between points | Scenario: Malformed requests Given the node locations @@ -55,7 +55,7 @@ Feature: Status messages | ? | 400 | Query string malformed close to position 0 | | viaroute?loc= | 400 | Query string malformed close to position 9 | | viaroute?loc=1 | 400 | Query string malformed close to position 9 | - | viaroute?loc=1,1 | 400 | Invalid coordinates. | + | viaroute?loc=1,1 | 400 | Invalid coordinates | | viaroute?loc=1,1,1 | 400 | Query string malformed close to position 17 | | viaroute?loc=x | 400 | Query string malformed close to position 9 | | viaroute?loc=x,y | 400 | Query string malformed close to position 9 | diff --git a/plugins/distance_table.hpp b/plugins/distance_table.hpp index 814c34061..7353c990e 100644 --- a/plugins/distance_table.hpp +++ b/plugins/distance_table.hpp @@ -72,7 +72,7 @@ template class DistanceTablePlugin final : public BasePlugin { if (!check_all_coordinates(route_parameters.coordinates)) { - json_result.values["status_message"] = "Coordinates are invalid."; + json_result.values["status_message"] = "Coordinates are invalid"; return Status::Error; } @@ -81,7 +81,7 @@ template class DistanceTablePlugin final : public BasePlugin route_parameters.coordinates.size() != input_bearings.size()) { json_result.values["status_message"] = - "Number of bearings does not match number of coordinates."; + "Number of bearings does not match number of coordinates"; return Status::Error; } @@ -203,7 +203,7 @@ template class DistanceTablePlugin final : public BasePlugin if (!result_table) { - json_result.values["status_message"] = "No distance table found."; + json_result.values["status_message"] = "No distance table found"; return Status::EmptyResult; } diff --git a/plugins/match.hpp b/plugins/match.hpp index efc754719..f1769562f 100644 --- a/plugins/match.hpp +++ b/plugins/match.hpp @@ -292,14 +292,14 @@ template class MapMatchingPlugin : public BasePlugin if (max_locations_map_matching > 0 && static_cast(route_parameters.coordinates.size()) > max_locations_map_matching) { - json_result.values["status_message"] = "Too many coodindates."; + json_result.values["status_message"] = "Too many coodindates"; return Status::Error; } // check number of parameters if (!check_all_coordinates(route_parameters.coordinates)) { - json_result.values["status_message"] = "Invalid coordinates."; + json_result.values["status_message"] = "Invalid coordinates"; return Status::Error; } @@ -310,21 +310,21 @@ template class MapMatchingPlugin : public BasePlugin if (input_timestamps.size() > 0 && input_coords.size() != input_timestamps.size()) { json_result.values["status_message"] = - "Number of timestamps does not match number of coordinates."; + "Number of timestamps does not match number of coordinates"; return Status::Error; } if (input_bearings.size() > 0 && input_coords.size() != input_bearings.size()) { json_result.values["status_message"] = - "Number of bearings does not match number of coordinates."; + "Number of bearings does not match number of coordinates"; return Status::Error; } // enforce maximum number of locations for performance reasons if (static_cast(input_coords.size()) < 2) { - json_result.values["status_message"] = "At least two coordinates needed."; + json_result.values["status_message"] = "At least two coordinates needed"; return Status::Error; } @@ -399,11 +399,11 @@ template class MapMatchingPlugin : public BasePlugin if (sub_matchings.empty()) { - json_result.values["status_message"] = "Cannot find matchings."; + json_result.values["status_message"] = "Cannot find matchings"; return Status::EmptyResult; } - json_result.values["status_message"] = "Found matchings."; + json_result.values["status_message"] = "Found matchings"; return Status::Ok; } diff --git a/plugins/nearest.hpp b/plugins/nearest.hpp index 534d0853f..245981981 100644 --- a/plugins/nearest.hpp +++ b/plugins/nearest.hpp @@ -64,7 +64,7 @@ template class NearestPlugin final : public BasePlugin route_parameters.coordinates.size() != input_bearings.size()) { json_result.values["status_message"] = - "Number of bearings does not match number of coordinates."; + "Number of bearings does not match number of coordinates"; return Status::Error; } @@ -80,12 +80,12 @@ template class NearestPlugin final : public BasePlugin if (phantom_node_vector.empty()) { json_result.values["status_message"] = - std::string("Could not find a matching segments for coordinate."); + std::string("Could not find a matching segments for coordinate"); return Status::NoSegment; } else { - json_result.values["status_message"] = "Found nearest edge."; + json_result.values["status_message"] = "Found nearest edge"; if (number_of_results > 1) { osrm::json::Array results; diff --git a/plugins/trip.hpp b/plugins/trip.hpp index 05794f2f2..6a7ce6419 100644 --- a/plugins/trip.hpp +++ b/plugins/trip.hpp @@ -263,7 +263,7 @@ template class RoundTripPlugin final : public BasePlugin // check if all inputs are coordinates if (!check_all_coordinates(route_parameters.coordinates)) { - json_result.values["status_message"] = "Invalid coordinates."; + json_result.values["status_message"] = "Invalid coordinates"; return Status::Error; } @@ -272,7 +272,7 @@ template class RoundTripPlugin final : public BasePlugin route_parameters.coordinates.size() != input_bearings.size()) { json_result.values["status_message"] = - "Number of bearings does not match number of coordinates."; + "Number of bearings does not match number of coordinates"; return Status::Error; } @@ -301,7 +301,7 @@ template class RoundTripPlugin final : public BasePlugin const constexpr std::size_t BF_MAX_FEASABLE = 10; BOOST_ASSERT_MSG(result_table.size() == number_of_locations * number_of_locations, - "Distance Table has wrong size."); + "Distance Table has wrong size"); // get scc components SCC_Component scc = SplitUnaccessibleLocations(number_of_locations, result_table); @@ -388,11 +388,11 @@ template class RoundTripPlugin final : public BasePlugin if (trip.values.empty()) { - json_result.values["status_message"] = "Cannot find trips."; + json_result.values["status_message"] = "Cannot find trips"; return Status::EmptyResult; } - json_result.values["status_message"] = "Found trips."; + json_result.values["status_message"] = "Found trips"; return Status::Ok; } }; diff --git a/plugins/viaroute.hpp b/plugins/viaroute.hpp index 0bd553474..f9a6737da 100644 --- a/plugins/viaroute.hpp +++ b/plugins/viaroute.hpp @@ -89,7 +89,7 @@ template class ViaRoutePlugin final : public BasePlugin if (!check_all_coordinates(route_parameters.coordinates)) { - json_result.values["status_message"] = "Invalid coordinates."; + json_result.values["status_message"] = "Invalid coordinates"; return Status::Error; } @@ -98,7 +98,7 @@ template class ViaRoutePlugin final : public BasePlugin route_parameters.coordinates.size() != input_bearings.size()) { json_result.values["status_message"] = - "Number of bearings does not match number of coordinates."; + "Number of bearings does not match number of coordinate"; return Status::Error; } @@ -196,10 +196,14 @@ template class ViaRoutePlugin final : public BasePlugin }); if (not_in_same_component) { - json_result.values["status_message"] = "Impossible route between points."; + json_result.values["status_message"] = "Impossible route between points"; return Status::EmptyResult; } } + else + { + json_result.values["status_message"] = "Found route between points"; + } return Status::Ok; }