mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
912e1faaf2
commit
9d2449c5c3
1 changed files with 4 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue