Prevents the Matching getting confused when users are time-travelling.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user