Fix handling unexpected errors.
This commit is contained in:
parent
f1140ec903
commit
88e6558da3
@ -164,28 +164,9 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
route_parameters.uturns, raw_route);
|
||||
}
|
||||
|
||||
bool no_route = INVALID_EDGE_WEIGHT == raw_route.shortest_path_length;
|
||||
|
||||
std::unique_ptr<BaseDescriptor<DataFacadeT>> descriptor;
|
||||
switch (descriptor_table.get_id(route_parameters.output_format))
|
||||
{
|
||||
case 1:
|
||||
descriptor = osrm::make_unique<GPXDescriptor<DataFacadeT>>(facade);
|
||||
break;
|
||||
// case 2:
|
||||
// descriptor = osrm::make_unique<GEOJSONDescriptor<DataFacadeT>>();
|
||||
// break;
|
||||
default:
|
||||
descriptor = osrm::make_unique<JSONDescriptor<DataFacadeT>>(facade);
|
||||
break;
|
||||
}
|
||||
|
||||
descriptor->SetConfig(route_parameters);
|
||||
descriptor->Run(raw_route, json_result);
|
||||
|
||||
// we can only know this after the fact, different SCC ids still
|
||||
// allow for connection in one direction.
|
||||
if (no_route)
|
||||
if (raw_route.shortest_path_length == INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
auto first_component_id = snapped_phantoms.front().component.id;
|
||||
auto not_in_same_component =
|
||||
@ -194,14 +175,36 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||
{
|
||||
return node.component.id != first_component_id;
|
||||
});
|
||||
|
||||
if (not_in_same_component)
|
||||
{
|
||||
json_result.values["status_message"] = "Impossible route between points";
|
||||
return Status::EmptyResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
json_result.values["status_message"] = "No route found between points";
|
||||
return Status::Error;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_ptr<BaseDescriptor<DataFacadeT>> descriptor;
|
||||
switch (descriptor_table.get_id(route_parameters.output_format))
|
||||
{
|
||||
case 1:
|
||||
descriptor = osrm::make_unique<GPXDescriptor<DataFacadeT>>(facade);
|
||||
break;
|
||||
// case 2:
|
||||
// descriptor = osrm::make_unique<GEOJSONDescriptor<DataFacadeT>>();
|
||||
// break;
|
||||
default:
|
||||
descriptor = osrm::make_unique<JSONDescriptor<DataFacadeT>>(facade);
|
||||
break;
|
||||
}
|
||||
|
||||
descriptor->SetConfig(route_parameters);
|
||||
descriptor->Run(raw_route, json_result);
|
||||
json_result.values["status_message"] = "Found route between points";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user