Prevents the Matching getting confused when users are time-travelling.
This commit is contained in:
parent
ba5871cfa1
commit
a933b5d949
@ -275,7 +275,7 @@ In addition to the [general options](#general-options) the following options are
|
||||
|geometries |`polyline` (default), `geojson` |Returned route geometry format (influences overview and per step) |
|
||||
|annotations |`true`, `false` (default) |Returns additional metadata for each coordinate along the route geometry. |
|
||||
|overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.|
|
||||
|timestamps |`{timestamp};{timestamp}[;{timestamp} ...]` |Timestamp of the input location. |
|
||||
|timestamps |`{timestamp};{timestamp}[;{timestamp} ...]` |Timestamp of the input location. Timestamps need to be monotonically increasing. |
|
||||
|radiuses |`{radius};{radius}[;{radius} ...]` |Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy.|
|
||||
|
||||
|Parameter |Values |
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -123,6 +125,16 @@ Status MatchPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFaca
|
||||
return Error("InvalidValue", "Invalid coordinate value.", 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(
|
||||
parameters.timestamps.rbegin(), parameters.timestamps.rend(), std::greater<>{});
|
||||
|
||||
if (!time_increases_monotonically)
|
||||
{
|
||||
return Error("InvalidValue", "Timestamps need to be monotonically increasing.", json_result);
|
||||
}
|
||||
|
||||
// assuming radius is the standard deviation of a normal distribution
|
||||
// that models GPS noise (in this model), x3 should give us the correct
|
||||
// search radius with > 99% confidence
|
||||
|
Loading…
Reference in New Issue
Block a user