mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Location service: make distance and time threshold configurable
Right now the distance is always in meters, the mobile app doesn't deal with units at all, anyway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
24404a401d
commit
76d0763527
7 changed files with 84 additions and 9 deletions
|
@ -43,10 +43,6 @@ void GpsLocation::serviceEnable(bool toggle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// these two need to become configurable
|
|
||||||
#define MINTIME 600
|
|
||||||
#define MINDIST 200
|
|
||||||
|
|
||||||
void GpsLocation::newPosition(QGeoPositionInfo pos)
|
void GpsLocation::newPosition(QGeoPositionInfo pos)
|
||||||
{
|
{
|
||||||
time_t lastTime;
|
time_t lastTime;
|
||||||
|
@ -61,7 +57,9 @@ void GpsLocation::newPosition(QGeoPositionInfo pos)
|
||||||
}
|
}
|
||||||
// if we have no record stored or if at least the configured minimum
|
// 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
|
// time has passed or we moved at least the configured minimum distance
|
||||||
if (!nr || pos.timestamp().toTime_t() > lastTime + MINTIME || lastCoord.distanceTo(pos.coordinate()) > MINDIST) {
|
if (!nr ||
|
||||||
|
pos.timestamp().toTime_t() > lastTime + prefs.time_threshold ||
|
||||||
|
lastCoord.distanceTo(pos.coordinate()) > prefs.distance_threshold) {
|
||||||
geoSettings->setValue("count", nr + 1);
|
geoSettings->setValue("count", nr + 1);
|
||||||
geoSettings->setValue(QString("gpsFix%1_time").arg(nr), pos.timestamp().toTime_t());
|
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));
|
geoSettings->setValue(QString("gpsFix%1_lat").arg(nr), rint(pos.coordinate().latitude() * 1000000));
|
||||||
|
|
|
@ -90,6 +90,28 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Distance threshold (meters)"
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: distanceThreshold
|
||||||
|
text: manager.distanceThreshold
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Time threshold (minutes)"
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: timeThreshold
|
||||||
|
text: manager.timeThreshold
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
Item { width: units.gridUnit; height: width }
|
Item { width: units.gridUnit; height: width }
|
||||||
Item {
|
Item {
|
||||||
height: saveButton.height
|
height: saveButton.height
|
||||||
|
@ -103,6 +125,8 @@ Item {
|
||||||
manager.cloudPassword = password.text
|
manager.cloudPassword = password.text
|
||||||
manager.saveCloudPassword = savePassword.checked
|
manager.saveCloudPassword = savePassword.checked
|
||||||
manager.ssrfGpsWebUserid = userid.text
|
manager.ssrfGpsWebUserid = userid.text
|
||||||
|
manager.distanceThreshold = distanceThreshold.text
|
||||||
|
manager.timeThreshold = timeThreshold.text
|
||||||
manager.savePreferences()
|
manager.savePreferences()
|
||||||
stackView.pop()
|
stackView.pop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ QMLManager::QMLManager() :
|
||||||
setCloudPassword(prefs.cloud_storage_password);
|
setCloudPassword(prefs.cloud_storage_password);
|
||||||
setSaveCloudPassword(prefs.save_password_local);
|
setSaveCloudPassword(prefs.save_password_local);
|
||||||
setSsrfGpsWebUserid(prefs.userid);
|
setSsrfGpsWebUserid(prefs.userid);
|
||||||
|
setDistanceThreshold(prefs.distance_threshold);
|
||||||
|
setTimeThreshold(prefs.time_threshold / 60);
|
||||||
if (!same_string(prefs.cloud_storage_email, "") && !same_string(prefs.cloud_storage_password, ""))
|
if (!same_string(prefs.cloud_storage_email, "") && !same_string(prefs.cloud_storage_password, ""))
|
||||||
loadDives();
|
loadDives();
|
||||||
}
|
}
|
||||||
|
@ -38,6 +40,12 @@ void QMLManager::savePreferences()
|
||||||
{
|
{
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.setValue("subsurface_webservice_uid", ssrfGpsWebUserid());
|
s.setValue("subsurface_webservice_uid", ssrfGpsWebUserid());
|
||||||
|
s.beginGroup("LocationService");
|
||||||
|
s.setValue("time_threshold", timeThreshold() * 60);
|
||||||
|
prefs.time_threshold = timeThreshold() * 60;
|
||||||
|
s.setValue("distance_threshold", distanceThreshold());
|
||||||
|
prefs.distance_threshold = distanceThreshold();
|
||||||
|
s.endGroup();
|
||||||
s.beginGroup("CloudStorage");
|
s.beginGroup("CloudStorage");
|
||||||
s.setValue("email", cloudUserName());
|
s.setValue("email", cloudUserName());
|
||||||
s.setValue("save_password_local", saveCloudPassword());
|
s.setValue("save_password_local", saveCloudPassword());
|
||||||
|
@ -240,3 +248,25 @@ void QMLManager::setSsrfGpsWebUserid(const QString &userid)
|
||||||
m_ssrfGpsWebUserid = userid;
|
m_ssrfGpsWebUserid = userid;
|
||||||
emit ssrfGpsWebUseridChanged();
|
emit ssrfGpsWebUseridChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QMLManager::distanceThreshold() const
|
||||||
|
{
|
||||||
|
return m_distanceThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMLManager::setDistanceThreshold(int distance)
|
||||||
|
{
|
||||||
|
m_distanceThreshold = distance;
|
||||||
|
emit distanceThresholdChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
int QMLManager::timeThreshold() const
|
||||||
|
{
|
||||||
|
return m_timeThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QMLManager::setTimeThreshold(int time)
|
||||||
|
{
|
||||||
|
m_timeThreshold = time;
|
||||||
|
emit timeThresholdChanged();
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ class QMLManager : public QObject
|
||||||
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
|
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
|
||||||
Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
|
Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
|
||||||
Q_PROPERTY(QString ssrfGpsWebUserid READ ssrfGpsWebUserid WRITE setSsrfGpsWebUserid NOTIFY ssrfGpsWebUseridChanged)
|
Q_PROPERTY(QString ssrfGpsWebUserid READ ssrfGpsWebUserid WRITE setSsrfGpsWebUserid NOTIFY ssrfGpsWebUseridChanged)
|
||||||
|
Q_PROPERTY(int distanceThreshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
|
||||||
|
Q_PROPERTY(int timeThreshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
|
||||||
public:
|
public:
|
||||||
QMLManager();
|
QMLManager();
|
||||||
~QMLManager();
|
~QMLManager();
|
||||||
|
@ -27,15 +29,21 @@ public:
|
||||||
QString cloudPassword() const;
|
QString cloudPassword() const;
|
||||||
void setCloudPassword(const QString &cloudPassword);
|
void setCloudPassword(const QString &cloudPassword);
|
||||||
|
|
||||||
QString ssrfGpsWebUserid() const;
|
|
||||||
void setSsrfGpsWebUserid(const QString &userid);
|
|
||||||
|
|
||||||
bool saveCloudPassword() const;
|
bool saveCloudPassword() const;
|
||||||
void setSaveCloudPassword(bool saveCloudPassword);
|
void setSaveCloudPassword(bool saveCloudPassword);
|
||||||
|
|
||||||
|
QString ssrfGpsWebUserid() const;
|
||||||
|
void setSsrfGpsWebUserid(const QString &userid);
|
||||||
|
|
||||||
bool locationServiceEnabled() const;
|
bool locationServiceEnabled() const;
|
||||||
void setLocationServiceEnabled(bool locationServiceEnable);
|
void setLocationServiceEnabled(bool locationServiceEnable);
|
||||||
|
|
||||||
|
int distanceThreshold() const;
|
||||||
|
void setDistanceThreshold(int distance);
|
||||||
|
|
||||||
|
int timeThreshold() const;
|
||||||
|
void setTimeThreshold(int time);
|
||||||
|
|
||||||
QString logText() const;
|
QString logText() const;
|
||||||
void setLogText(const QString &logText);
|
void setLogText(const QString &logText);
|
||||||
void appendTextToLog(const QString &newText);
|
void appendTextToLog(const QString &newText);
|
||||||
|
@ -57,6 +65,8 @@ private:
|
||||||
bool m_saveCloudPassword;
|
bool m_saveCloudPassword;
|
||||||
QString m_logText;
|
QString m_logText;
|
||||||
bool m_locationServiceEnabled;
|
bool m_locationServiceEnabled;
|
||||||
|
int m_distanceThreshold;
|
||||||
|
int m_timeThreshold;
|
||||||
GpsLocation *locationProvider;
|
GpsLocation *locationProvider;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -66,6 +76,8 @@ signals:
|
||||||
void saveCloudPasswordChanged();
|
void saveCloudPasswordChanged();
|
||||||
void locationServiceEnabledChanged();
|
void locationServiceEnabledChanged();
|
||||||
void logTextChanged();
|
void logTextChanged();
|
||||||
|
void timeThresholdChanged();
|
||||||
|
void distanceThresholdChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -123,6 +123,8 @@ struct preferences {
|
||||||
geocoding_prefs_t geocoding;
|
geocoding_prefs_t geocoding;
|
||||||
enum deco_mode deco_mode;
|
enum deco_mode deco_mode;
|
||||||
short conservatism_level;
|
short conservatism_level;
|
||||||
|
int time_threshold;
|
||||||
|
int distance_threshold;
|
||||||
};
|
};
|
||||||
enum unit_system_values {
|
enum unit_system_values {
|
||||||
METRIC,
|
METRIC,
|
||||||
|
|
|
@ -1601,6 +1601,13 @@ void loadPreferences()
|
||||||
// Subsurface webservice id is stored outside of the groups
|
// Subsurface webservice id is stored outside of the groups
|
||||||
GET_TXT("subsurface_webservice_uid", userid);
|
GET_TXT("subsurface_webservice_uid", userid);
|
||||||
|
|
||||||
|
// but the related time / distance threshold (only used in the mobile app)
|
||||||
|
// are in their own group
|
||||||
|
s.beginGroup("locationService");
|
||||||
|
GET_INT("distance_threshold", distance_threshold);
|
||||||
|
GET_INT("time_threshold", time_threshold);
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
// GeoManagement
|
// GeoManagement
|
||||||
s.beginGroup("geocoding");
|
s.beginGroup("geocoding");
|
||||||
#ifdef DISABLED
|
#ifdef DISABLED
|
||||||
|
|
|
@ -79,7 +79,9 @@ struct preferences default_prefs = {
|
||||||
.category = { 0 }
|
.category = { 0 }
|
||||||
},
|
},
|
||||||
.deco_mode = BUEHLMANN,
|
.deco_mode = BUEHLMANN,
|
||||||
.conservatism_level = 3
|
.conservatism_level = 3,
|
||||||
|
.distance_threshold = 1000,
|
||||||
|
.time_threshold = 600
|
||||||
};
|
};
|
||||||
|
|
||||||
int run_survey;
|
int run_survey;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue