1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Improved time sequence checking

This commit is contained in:
Martin Tůma 2018-02-17 13:40:25 +01:00
parent da06c032bc
commit 586f30a337

View File

@ -75,28 +75,32 @@ static Graph filter(const Graph &g, int window)
Track::Track(const TrackData &data) : _data(data) Track::Track(const TrackData &data) : _data(data)
{ {
qreal dt, ds, total; qreal dt, ds, total;
int last;
_time.append(0); _time.append(0);
_distance.append(0); _distance.append(0);
_speed.append(0); _speed.append(0);
last = 0;
for (int i = 1; i < _data.count(); i++) { for (int i = 1; i < _data.count(); i++) {
ds = _data.at(i).coordinates().distanceTo(_data.at(i-1).coordinates()); ds = _data.at(i).coordinates().distanceTo(_data.at(i-1).coordinates());
_distance.append(ds); _distance.append(ds);
if (_data.first().hasTimestamp() && _data.at(i).hasTimestamp() if (_data.first().hasTimestamp() && _data.at(i).hasTimestamp()
&& _data.at(i).timestamp() > _data.at(i-1).timestamp()) && _data.at(i).timestamp() > _data.at(last).timestamp()) {
_time.append(_data.first().timestamp().msecsTo( _time.append(_data.first().timestamp().msecsTo(
_data.at(i).timestamp()) / 1000.0); _data.at(i).timestamp()) / 1000.0);
else last = i;
} else
_time.append(NAN); _time.append(NAN);
if (std::isnan(_time.at(i)) || std::isnan(_time.at(i-1))) if (std::isnan(_time.at(i)) || std::isnan(_time.at(i-1)))
_speed.append(NAN); _speed.append(NAN);
else { else {
dt = _time.at(i) - _time.at(i-1); dt = _time.at(i) - _time.at(i-1);
if (!dt) { if (dt < 1e-3) {
_speed.append(_speed.at(i-1)); _speed.append(_speed.at(i-1));
continue; continue;
} }