Fix status messages and don't include
This commit is contained in:
parent
c27fc4e4d8
commit
57f257dce5
@ -103,8 +103,6 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
|||||||
if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length)
|
if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length)
|
||||||
{
|
{
|
||||||
// We do not need to do much, if there is no route ;-)
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +113,6 @@ template <class DataFacadeT> class JSONDescriptor final : public BaseDescriptor<
|
|||||||
description_factory.SetStartSegment(
|
description_factory.SetStartSegment(
|
||||||
raw_route.segment_end_coordinates.front().source_phantom,
|
raw_route.segment_end_coordinates.front().source_phantom,
|
||||||
raw_route.source_traversed_in_reverse.front());
|
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 each unpacked segment add the leg to the description
|
||||||
for (const auto i : osrm::irange<std::size_t>(0, raw_route.unpacked_path_segments.size()))
|
for (const auto i : osrm::irange<std::size_t>(0, raw_route.unpacked_path_segments.size()))
|
||||||
|
@ -32,8 +32,8 @@ Feature: Status messages
|
|||||||
| from | to | route | status | message |
|
| from | to | route | status | message |
|
||||||
| a | b | ab | 200 | Found route between points |
|
| a | b | ab | 200 | Found route between points |
|
||||||
| c | d | cd | 200 | Found route between points |
|
| c | d | cd | 200 | Found route between points |
|
||||||
| a | c | | 207 | Impossible route between points. |
|
| a | c | | 207 | Impossible route between points |
|
||||||
| b | d | | 207 | Impossible route between points. |
|
| b | d | | 207 | Impossible route between points |
|
||||||
|
|
||||||
Scenario: Malformed requests
|
Scenario: Malformed requests
|
||||||
Given the node locations
|
Given the node locations
|
||||||
@ -55,7 +55,7 @@ Feature: Status messages
|
|||||||
| ? | 400 | Query string malformed close to position 0 |
|
| ? | 400 | Query string malformed close to position 0 |
|
||||||
| viaroute?loc= | 400 | Query string malformed close to position 9 |
|
| viaroute?loc= | 400 | Query string malformed close to position 9 |
|
||||||
| viaroute?loc=1 | 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=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 | 400 | Query string malformed close to position 9 |
|
||||||
| viaroute?loc=x,y | 400 | Query string malformed close to position 9 |
|
| viaroute?loc=x,y | 400 | Query string malformed close to position 9 |
|
||||||
|
@ -72,7 +72,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
{
|
{
|
||||||
if (!check_all_coordinates(route_parameters.coordinates))
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
route_parameters.coordinates.size() != input_bearings.size())
|
route_parameters.coordinates.size() != input_bearings.size())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
|
|
||||||
if (!result_table)
|
if (!result_table)
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] = "No distance table found.";
|
json_result.values["status_message"] = "No distance table found";
|
||||||
return Status::EmptyResult;
|
return Status::EmptyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,14 +292,14 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
if (max_locations_map_matching > 0 &&
|
if (max_locations_map_matching > 0 &&
|
||||||
static_cast<int>(route_parameters.coordinates.size()) > max_locations_map_matching)
|
static_cast<int>(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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check number of parameters
|
// check number of parameters
|
||||||
if (!check_all_coordinates(route_parameters.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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,21 +310,21 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
if (input_timestamps.size() > 0 && input_coords.size() != input_timestamps.size())
|
if (input_timestamps.size() > 0 && input_coords.size() != input_timestamps.size())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_bearings.size() > 0 && input_coords.size() != input_bearings.size())
|
if (input_bearings.size() > 0 && input_coords.size() != input_bearings.size())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforce maximum number of locations for performance reasons
|
// enforce maximum number of locations for performance reasons
|
||||||
if (static_cast<int>(input_coords.size()) < 2)
|
if (static_cast<int>(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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,11 +399,11 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
|
|
||||||
if (sub_matchings.empty())
|
if (sub_matchings.empty())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] = "Cannot find matchings.";
|
json_result.values["status_message"] = "Cannot find matchings";
|
||||||
return Status::EmptyResult;
|
return Status::EmptyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_result.values["status_message"] = "Found matchings.";
|
json_result.values["status_message"] = "Found matchings";
|
||||||
return Status::Ok;
|
return Status::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
|||||||
route_parameters.coordinates.size() != input_bearings.size())
|
route_parameters.coordinates.size() != input_bearings.size())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +80,12 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
|||||||
if (phantom_node_vector.empty())
|
if (phantom_node_vector.empty())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::NoSegment;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] = "Found nearest edge.";
|
json_result.values["status_message"] = "Found nearest edge";
|
||||||
if (number_of_results > 1)
|
if (number_of_results > 1)
|
||||||
{
|
{
|
||||||
osrm::json::Array results;
|
osrm::json::Array results;
|
||||||
|
@ -263,7 +263,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
// check if all inputs are coordinates
|
// check if all inputs are coordinates
|
||||||
if (!check_all_coordinates(route_parameters.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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
route_parameters.coordinates.size() != input_bearings.size())
|
route_parameters.coordinates.size() != input_bearings.size())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
|
|
||||||
const constexpr std::size_t BF_MAX_FEASABLE = 10;
|
const constexpr std::size_t BF_MAX_FEASABLE = 10;
|
||||||
BOOST_ASSERT_MSG(result_table.size() == number_of_locations * number_of_locations,
|
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
|
// get scc components
|
||||||
SCC_Component scc = SplitUnaccessibleLocations(number_of_locations, result_table);
|
SCC_Component scc = SplitUnaccessibleLocations(number_of_locations, result_table);
|
||||||
@ -388,11 +388,11 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
|
|
||||||
if (trip.values.empty())
|
if (trip.values.empty())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] = "Cannot find trips.";
|
json_result.values["status_message"] = "Cannot find trips";
|
||||||
return Status::EmptyResult;
|
return Status::EmptyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
json_result.values["status_message"] = "Found trips.";
|
json_result.values["status_message"] = "Found trips";
|
||||||
return Status::Ok;
|
return Status::Ok;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -89,7 +89,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
|
|
||||||
if (!check_all_coordinates(route_parameters.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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
route_parameters.coordinates.size() != input_bearings.size())
|
route_parameters.coordinates.size() != input_bearings.size())
|
||||||
{
|
{
|
||||||
json_result.values["status_message"] =
|
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;
|
return Status::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,10 +196,14 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
});
|
});
|
||||||
if (not_in_same_component)
|
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;
|
return Status::EmptyResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
json_result.values["status_message"] = "Found route between points";
|
||||||
|
}
|
||||||
|
|
||||||
return Status::Ok;
|
return Status::Ok;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user