diff options
-rw-r--r-- | subsurface-core/gpslocation.cpp | 5 | ||||
-rw-r--r-- | subsurface-core/gpslocation.h | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp index 5790bc2d8..5fe637137 100644 --- a/subsurface-core/gpslocation.cpp +++ b/subsurface-core/gpslocation.cpp @@ -20,6 +20,7 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent) Q_ASSERT_X(m_Instance == NULL, "GpsLocation", "GpsLocation recreated"); m_Instance = this; m_GpsSource = 0; + waitingForPosition = false; showMessageCB = showMsgCB; // create a QSettings object that's separate from the main application settings geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope, @@ -100,11 +101,13 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) lastCoord.setLongitude(geoSettings->value(QString("gpsFix%1_lon").arg(nr - 1)).toInt() / 1000000.0); lastTime = geoSettings->value(QString("gpsFix%1_time").arg(nr - 1)).toULongLong(); } + // 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 || + if (!nr || waitingForPosition || (time_t)pos.timestamp().toTime_t() > lastTime + prefs.time_threshold || lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) { + waitingForPosition = false; geoSettings->setValue("count", nr + 1); geoSettings->setValue(QString("gpsFix%1_time").arg(nr), pos.timestamp().toTime_t()); geoSettings->setValue(QString("gpsFix%1_lat").arg(nr), rint(pos.coordinate().latitude() * 1000000)); diff --git a/subsurface-core/gpslocation.h b/subsurface-core/gpslocation.h index c527fdd2a..0adcfdc29 100644 --- a/subsurface-core/gpslocation.h +++ b/subsurface-core/gpslocation.h @@ -31,6 +31,7 @@ private: QString userAgent; void (*showMessageCB)(const char *msg); static GpsLocation *m_Instance; + bool waitingForPosition; public slots: void serviceEnable(bool toggle); |