diff options
Diffstat (limited to 'subsurface-core/gpslocation.cpp')
-rw-r--r-- | subsurface-core/gpslocation.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp index 9f1961cbf..075b1c046 100644 --- a/subsurface-core/gpslocation.cpp +++ b/subsurface-core/gpslocation.cpp @@ -33,7 +33,7 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) : QOb QString("org.subsurfacedivelog"), QString("subsurfacelocation"), this); #ifdef SUBSURFACE_MOBILE if (hasLocationsSource()) - status("Found GPS"); + status(QString("Found GPS with positioning methods %1").arg(QString::number(m_GpsSource->supportedPositioningMethods(), 16))); #endif userAgent = getUserAgent(); loadFromStorage(); @@ -59,8 +59,7 @@ QGeoPositionInfoSource *GpsLocation::getGpsSource() #ifndef SUBSURFACE_MOBILE if (verbose) #endif - status("created GPS source"); - QString msg = QString("have position source %1").arg(m_GpsSource->sourceName()); + status(QString("Created position source %1").arg(m_GpsSource->sourceName())); connect(m_GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo))); connect(m_GpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); m_GpsSource->setUpdateInterval(5 * 60 * 1000); // 5 minutes so the device doesn't drain the battery @@ -89,7 +88,7 @@ void GpsLocation::serviceEnable(bool toggle) } if (toggle) { gpsSource->startUpdates(); - status("Starting Subsurface GPS service"); + status(QString("Starting Subsurface GPS service with update interval %1").arg(gpsSource->updateInterval())); } else { gpsSource->stopUpdates(); status("Stopping Subsurface GPS service"); @@ -117,10 +116,8 @@ QString GpsLocation::currentPosition() void GpsLocation::newPosition(QGeoPositionInfo pos) { - int64_t lastTime; + int64_t lastTime = 0; QGeoCoordinate lastCoord; - QString msg("received new position %1"); - status(qPrintable(msg.arg(pos.coordinate().toString()))); int nr = m_trackers.count(); if (nr) { gpsTracker gt = m_trackers.last(); @@ -131,9 +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 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(); |