diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-07-06 14:37:39 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-07-11 11:47:43 -0700 |
commit | 9d2449c5c302a67044f4a7d6802a38bafa477ecc (patch) | |
tree | 71a90b22fa2e3bc39bf7b5b0c651e8c9cfd98da6 | |
parent | 912e1faaf21afbfac0cec07db036d97b13ed847c (diff) | |
download | subsurface-9d2449c5c302a67044f4a7d6802a38bafa477ecc.tar.gz |
mobile/location-service: fix timezone issue in GPS timestamps
For some reason we suddenly started logging the GPS fixes in UTC instead
of local time. Which caused the matching algorithm to fail (unless you
happened to be diving in UTC). Unclear what broke this, but this seems
like an easy enough fix, since the GPS fix being reported is by
definition "right around now". So using gettimezoneoffset() with the
current time seems "good enough".
I don't know when gettimezoneoffset() with an argument got broken, TBH.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/gpslocation.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index cc11fa15e..2d63b42f5 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -158,6 +158,7 @@ QString GpsLocation::currentPosition() void GpsLocation::newPosition(QGeoPositionInfo pos) { int64_t lastTime = 0; + int64_t thisTime = dateTimeToTimestamp(pos.timestamp()) + gettimezoneoffset(); QGeoCoordinate lastCoord; int nr = m_trackers.count(); if (nr) { @@ -169,7 +170,7 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) // if we are waiting for a position update or // if we have no record stored or if at least the configured minimum // time has passed or we moved at least the configured minimum distance - int64_t delta = dateTimeToTimestamp(pos.timestamp()) + gettimezoneoffset() - lastTime; + int64_t delta = thisTime - lastTime; if (!nr || waitingForPosition || delta > prefs.time_threshold || lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) { QString msg = QStringLiteral("received new position %1 after delta %2 threshold %3 (now %4 last %5)"); @@ -177,12 +178,11 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) waitingForPosition = false; acquiredPosition(); gpsTracker gt; - gt.when = dateTimeToTimestamp(pos.timestamp()); - gt.when += gettimezoneoffset(gt.when); + gt.when = thisTime; gt.location = create_location(pos.coordinate().latitude(), pos.coordinate().longitude()); addFixToStorage(gt); gpsTracker gtNew = m_trackers.last(); - qDebug() << "newest fix is now at" << timestampToDateTime(gtNew.when - gettimezoneoffset(gtNew.when)).toString(); + qDebug() << "newest fix is now at" << timestampToDateTime(gtNew.when - gettimezoneoffset()).toString(); } } |