add osrm-routed and node-osrm flags to configure mapmatching radius limit (#4721)
This commit is contained in:
@@ -11,12 +11,13 @@ bool EngineConfig::IsValid() const
|
||||
// leads to an empty path
|
||||
const bool all_path_are_empty = storage_config.GetPath("").empty();
|
||||
|
||||
const auto unlimited_or_more_than = [](const int v, const int limit) {
|
||||
const auto unlimited_or_more_than = [](const auto v, const auto limit) {
|
||||
return v == -1 || v > limit;
|
||||
};
|
||||
|
||||
const bool limits_valid = unlimited_or_more_than(max_locations_distance_table, 2) &&
|
||||
unlimited_or_more_than(max_locations_map_matching, 2) &&
|
||||
unlimited_or_more_than(max_radius_map_matching, 0) &&
|
||||
unlimited_or_more_than(max_locations_trip, 2) &&
|
||||
unlimited_or_more_than(max_locations_viaroute, 2) &&
|
||||
unlimited_or_more_than(max_results_nearest, 0) &&
|
||||
|
||||
@@ -139,6 +139,17 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
|
||||
return Error("InvalidValue", "Invalid coordinate value.", json_result);
|
||||
}
|
||||
|
||||
if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
|
||||
parameters.radiuses.end(),
|
||||
[&](const auto &radius) {
|
||||
if (!radius)
|
||||
return false;
|
||||
return *radius > max_radius_map_matching;
|
||||
}))
|
||||
{
|
||||
return Error("TooBig", "Radius search size is too large for map matching.", json_result);
|
||||
}
|
||||
|
||||
// Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
|
||||
// last, less_equal)` checking `greater` in reverse meets irreflexive requirements.
|
||||
const auto time_increases_monotonically = std::is_sorted(
|
||||
|
||||
@@ -76,8 +76,9 @@ NAN_MODULE_INIT(Engine::Init)
|
||||
* @param {Number} [options.max_locations_viaroute] Max. locations supported in viaroute query (default: unlimited).
|
||||
* @param {Number} [options.max_locations_distance_table] Max. locations supported in distance table query (default: unlimited).
|
||||
* @param {Number} [options.max_locations_map_matching] Max. locations supported in map-matching query (default: unlimited).
|
||||
* @param {Number} [options.max_radius_map_matching] Max. radius size supported in map matching query (default: 5).
|
||||
* @param {Number} [options.max_results_nearest] Max. results supported in nearest query (default: unlimited).
|
||||
* @param {Number} [options.max_alternatives] Max.number of alternatives supported in alternative routes query (default: 3).
|
||||
* @param {Number} [options.max_alternatives] Max. number of alternatives supported in alternative routes query (default: 3).
|
||||
*
|
||||
* @class OSRM
|
||||
*
|
||||
|
||||
@@ -133,7 +133,10 @@ inline unsigned generateServerProgramOptions(const int argc,
|
||||
"Max. results supported in nearest query") //
|
||||
("max-alternatives",
|
||||
value<int>(&config.max_alternatives)->default_value(3),
|
||||
"Max. number of alternatives supported in the MLD route query");
|
||||
"Max. number of alternatives supported in the MLD route query") //
|
||||
("max-matching-radius",
|
||||
value<double>(&config.max_radius_map_matching)->default_value(5),
|
||||
"Max. radius size supported in map matching query");
|
||||
|
||||
// hidden options, will be allowed on command line, but will not be shown to the user
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
|
||||
Reference in New Issue
Block a user