aboutsummaryrefslogtreecommitdiffstats
path: root/subsurface-core/gpslocation.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-01 17:20:30 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-01 17:26:14 -0800
commit66cd83a70fcf315f639355eb191c57ca749b7eb4 (patch)
treedc955d12a5860ad83235d25cd06a1cff4a774df3 /subsurface-core/gpslocation.cpp
parenta611bb22f7dedd0377397c2e42a2bb9d6e1a4110 (diff)
downloadsubsurface-66cd83a70fcf315f639355eb191c57ca749b7eb4.tar.gz
Location service: support the concept of waiting for a position
There may be reasons where we want to get the position even if the criteria aren't met. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/gpslocation.cpp')
-rw-r--r--subsurface-core/gpslocation.cpp5
1 files changed, 4 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));