mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Location service: get the current position
If we have a fix that is fewer than 5 minutes old, take it, otherwise trigger an update. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
66cd83a70f
commit
14a09689a4
2 changed files with 24 additions and 0 deletions
|
@ -89,6 +89,29 @@ void GpsLocation::serviceEnable(bool toggle)
|
|||
}
|
||||
}
|
||||
|
||||
QString GpsLocation::currentPosition()
|
||||
{
|
||||
if (!hasLocationsSource())
|
||||
return tr("Unknown GPS location");
|
||||
int nr = geoSettings->value("count", 0).toInt();
|
||||
if (nr) {
|
||||
qDebug() << "last fix at" << geoSettings->value(QString("gpsFix%1_time").arg(nr - 1)).toULongLong() <<
|
||||
"right now" << QDateTime::currentMSecsSinceEpoch() / 1000;
|
||||
if (geoSettings->value(QString("gpsFix%1_time").arg(nr - 1)).toULongLong() + 300 > QDateTime::currentMSecsSinceEpoch() / 1000) {
|
||||
QString gpsString = printGPSCoords(geoSettings->value(QString("gpsFix%1_lat").arg(nr - 1)).toInt(),
|
||||
geoSettings->value(QString("gpsFix%1_lon").arg(nr - 1)).toInt());
|
||||
qDebug() << "returning last position" << gpsString;
|
||||
return gpsString;
|
||||
}
|
||||
}
|
||||
qDebug() << "requesting new GPS position";
|
||||
m_GpsSource->requestUpdate();
|
||||
// ok, we need to get the current position and somehow in the callback update the location in the QML UI
|
||||
// punting right now
|
||||
waitingForPosition = true;
|
||||
return QString("waiting for the next gps location");
|
||||
}
|
||||
|
||||
void GpsLocation::newPosition(QGeoPositionInfo pos)
|
||||
{
|
||||
time_t lastTime;
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
int getGpsNum() const;
|
||||
QString getUserid(QString user, QString passwd);
|
||||
bool hasLocationsSource();
|
||||
QString currentPosition();
|
||||
|
||||
private:
|
||||
QGeoPositionInfo lastPos;
|
||||
|
|
Loading…
Reference in a new issue