summaryrefslogtreecommitdiffstats
path: root/subsurface-core/gpslocation.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-24 11:50:32 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-24 11:50:51 -0700
commitf298802b99295376ef2c2b6c4acc2a8693240961 (patch)
treee834b0b13045945dee3b57e487c96d75a95cca44 /subsurface-core/gpslocation.cpp
parentb1037abdb7ea59b4f437b22cd42a9a0f7ef88d09 (diff)
downloadsubsurface-f298802b99295376ef2c2b6c4acc2a8693240961.tar.gz
QML UI: GPS location service - correctly calculate the delta
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/gpslocation.cpp')
-rw-r--r--subsurface-core/gpslocation.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp
index 399ed6997..2586f5fb0 100644
--- a/subsurface-core/gpslocation.cpp
+++ b/subsurface-core/gpslocation.cpp
@@ -116,7 +116,7 @@ QString GpsLocation::currentPosition()
void GpsLocation::newPosition(QGeoPositionInfo pos)
{
- int64_t lastTime;
+ int64_t lastTime = 0;
QGeoCoordinate lastCoord;
int nr = m_trackers.count();
if (nr) {
@@ -128,11 +128,11 @@ 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
- if (!nr || waitingForPosition ||
- (int64_t)pos.timestamp().toTime_t() > lastTime + prefs.time_threshold ||
+ int64_t delta = (int64_t)pos.timestamp().toTime_t() + gettimezoneoffset() - lastTime;
+ if (!nr || waitingForPosition || delta > prefs.time_threshold ||
lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) {
- QString msg("received new position %1");
- status(qPrintable(msg.arg(pos.coordinate().toString())));
+ QString msg("received new position %1 after delta %2 threshold %3");
+ status(qPrintable(msg.arg(pos.coordinate().toString()).arg(delta).arg(prefs.time_threshold)));
waitingForPosition = false;
gpsTracker gt;
gt.when = pos.timestamp().toTime_t();