This commit is contained in:
Whytro 2025-02-12 23:01:39 +05:30 committed by GitHub
commit bd757e86b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 39 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# Unreleased
- Changes from 5.27.1
- API:
- CHANGED: Require a `radius` parameter when using `bearings`. [#6572](https://github.com/Project-OSRM/osrm-backend/pull/6572)
- Features
- ADDED: Route pedestrians over highway=platform [#6993](https://github.com/Project-OSRM/osrm-backend/pull/6993)
- REMOVED: Remove all core-CH left-overs [#6920](https://github.com/Project-OSRM/osrm-backend/pull/6920)

View File

@ -31,7 +31,7 @@ To pass parameters to each location some options support an array-like encoding:
| Option | Values | Description |
|----------------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in a clockwise direction. |
|bearings |`{bearing};{bearing}[;{bearing} ...]` |Limits the search to segments with given bearing in degrees towards true north in a clockwise direction. Requires a corresponding radius or set default_radius flag. |
|radiuses |`{radius};{radius}[;{radius} ...]` |Limits the search to given radius in meters. |
|generate\_hints |`true` (default), `false` |Adds a Hint to the response which can be used in subsequent requests, see `hints` parameter. |
|hints |`{hint};{hint}[;{hint} ...]` |Hint from previous request to derive position in street network. |

View File

@ -591,6 +591,14 @@ inline bool argumentsToParameter(const Napi::CallbackInfo &args,
return false;
}
if (!obj.Has("radiuses") && default_radius.IsUndefined())
{
ThrowError(
args.Env(),
"Bearings must be accompanied with radiuses or a default_radius must be set.");
return false;
}
auto bearings_array = bearings.As<Napi::Array>();
if (bearings_array.Length() != params->coordinates.size())

View File

@ -132,6 +132,13 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
return Error("InvalidValue", "Invalid coordinate value.", result);
}
if (!parameters.bearings.empty() && !default_radius.has_value() &&
parameters.radiuses.size() != parameters.bearings.size())
{
return Error(
"InvalidOptions", "Number of radiuses does not match number of bearings", result);
}
if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
parameters.radiuses.end(),
[&](const auto &radius)

View File

@ -43,6 +43,13 @@ Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms
return Error("InvalidOptions", "Only one input coordinate is supported", result);
}
if (!params.bearings.empty() && !default_radius.has_value() &&
params.radiuses.size() != params.bearings.size())
{
return Error(
"InvalidOptions", "Number of radiuses does not match number of bearings", result);
}
auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results);
if (phantom_nodes.front().size() == 0)

View File

@ -44,6 +44,13 @@ Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
"InvalidOptions", "Number of bearings does not match number of coordinates", result);
}
if (!params.bearings.empty() && !default_radius.has_value() &&
params.radiuses.size() != params.bearings.size())
{
return Error(
"InvalidOptions", "Number of radiuses does not match number of bearings", result);
}
// Empty sources or destinations means the user wants all of them included, respectively
// The ManyToMany routing algorithm we dispatch to below already handles this perfectly.
const auto num_sources =

View File

@ -82,6 +82,13 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
if (!CheckAlgorithms(route_parameters, algorithms, result))
return Status::Error;
if (!route_parameters.bearings.empty() && !default_radius.has_value() &&
route_parameters.radiuses.size() != route_parameters.bearings.size())
{
return Error(
"InvalidOptions", "Number of radiuses does not match number of bearings", result);
}
const auto &facade = algorithms.GetFacade();
auto phantom_node_pairs = GetPhantomNodes(facade, route_parameters);
if (phantom_node_pairs.size() != route_parameters.coordinates.size())