Skip to content

Commit

Permalink
Merge pull request #51591 from 3nids/settings-gps-2
Browse files Browse the repository at this point in the history
[settings] migrate more gps settings
  • Loading branch information
3nids committed Jan 27, 2023
2 parents b3e4295 + 46a3684 commit 33368d7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_generated/gps/qgsgpslogger.sip.in
Expand Up @@ -11,6 +11,7 @@




class QgsGpsLogger : QObject
{
%Docstring(signature="appended")
Expand All @@ -28,6 +29,12 @@ from incoming GPS location points.
public:








QgsGpsLogger( QgsGpsConnection *connection, QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsGpsLogger with the specified ``parent`` object.
Expand Down
12 changes: 6 additions & 6 deletions src/app/options/qgsgpsoptions.cpp
Expand Up @@ -209,18 +209,18 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
gpsdPort = settings.value( QStringLiteral( "gpsdPort" ), 2947, QgsSettings::Gps ).toInt();
gpsdDevice = settings.value( QStringLiteral( "gpsdDevice" ), QVariant(), QgsSettings::Gps ).toString();

acquisitionInterval = settings.value( QStringLiteral( "acquisitionInterval" ), 0, QgsSettings::Gps ).toInt();
distanceThreshold = settings.value( QStringLiteral( "distanceThreshold" ), 0, QgsSettings::Gps ).toDouble();
acquisitionInterval = QgsGpsLogger::settingsAcquisitionInterval->value();
distanceThreshold = QgsGpsLogger::settingsDistanceThreshold->value();

bearingFromTravelDirection = settings.value( QStringLiteral( "calculateBearingFromTravel" ), "false", QgsSettings::Gps ).toBool();

recenteringThreshold = settings.value( QStringLiteral( "mapExtentMultiplier" ), "50", QgsSettings::Gps ).toInt();
rotateInterval = settings.value( QStringLiteral( "rotateMapInterval" ), 0, QgsSettings::Gps ).toInt();

applyLeapSeconds = settings.value( QStringLiteral( "applyLeapSeconds" ), true, QgsSettings::Gps ).toBool();
leapSeconds = settings.value( QStringLiteral( "leapSecondsCorrection" ), 18, QgsSettings::Gps ).toInt();
applyLeapSeconds = QgsGpsLogger::settingsApplyLeapSeconds->value();
leapSeconds = QgsGpsLogger::settingsLeapSecondsCorrection->value();

switch ( settings.value( QStringLiteral( "timeStampFormat" ), Qt::LocalTime, QgsSettings::Gps ).toInt() )
switch ( QgsGpsLogger::settingsTimeStampFormat->value() )
{
case 0:
timeSpec = Qt::TimeSpec::LocalTime;
Expand All @@ -234,7 +234,7 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
timeSpec = Qt::TimeSpec::TimeZone;
break;
}
timeZone = settings.value( QStringLiteral( "timestampTimeZone" ), QVariant(), QgsSettings::Gps ).toString();
timeZone = QgsGpsLogger::settingsTimestampTimeZone->value();
}

mOffsetFromUtc->setValue( offsetFromUtc );
Expand Down
23 changes: 17 additions & 6 deletions src/core/gps/qgsgpslogger.cpp
Expand Up @@ -23,6 +23,17 @@
#include <QTimer>
#include <QTimeZone>

#include "qgssettingsentryimpl.h"

const QgsSettingsEntryDouble *QgsGpsLogger::settingsDistanceThreshold = new QgsSettingsEntryDouble( QStringLiteral( "distanceThreshold" ), QgsSettings::sTreeGps, 0 );
const QgsSettingsEntryBool *QgsGpsLogger::settingsApplyLeapSeconds = new QgsSettingsEntryBool( QStringLiteral( "applyLeapSeconds" ), QgsSettings::sTreeGps, true );
const QgsSettingsEntryString *QgsGpsLogger::settingsTimestampTimeZone = new QgsSettingsEntryString( QStringLiteral( "timestampTimeZone" ), QgsSettings::sTreeGps, QString() );
const QgsSettingsEntryInteger *QgsGpsLogger::settingsTimeStampFormat = new QgsSettingsEntryInteger( QStringLiteral( "timeStampFormat" ), QgsSettings::sTreeGps, Qt::LocalTime );
const QgsSettingsEntryInteger *QgsGpsLogger::settingsLeapSecondsCorrection = new QgsSettingsEntryInteger( QStringLiteral( "leapSecondsCorrection" ), QgsSettings::sTreeGps, 18 );
const QgsSettingsEntryInteger *QgsGpsLogger::settingsAcquisitionInterval = new QgsSettingsEntryInteger( QStringLiteral( "acquisitionInterval" ), QgsSettings::sTreeGps, 0 );



const QgsSettingsEntryEnumFlag<Qgis::GpsInformationComponent> *QgsGpsLogger::settingsGpsMValueComponent = new QgsSettingsEntryEnumFlag<Qgis::GpsInformationComponent>( QStringLiteral( "m-value-attribute" ), QgsSettings::sTreeGps, Qgis::GpsInformationComponent::Timestamp, QStringLiteral( "Which GPS attribute should be stored in geometry m values" ) ) SIP_SKIP;

const QgsSettingsEntryBool *QgsGpsLogger::settingsGpsStoreAttributeInMValues = new QgsSettingsEntryBool( QStringLiteral( "store-attribute-in-m-values" ), QgsSettings::sTreeGps, false, QStringLiteral( "Whether GPS attributes should be stored in geometry m values" ) ) SIP_SKIP;
Expand Down Expand Up @@ -225,12 +236,12 @@ void QgsGpsLogger::updateGpsSettings()
// legacy settings
QgsSettings settings;

acquisitionInterval = settings.value( QStringLiteral( "acquisitionInterval" ), 0, QgsSettings::Gps ).toInt();
mDistanceThreshold = settings.value( QStringLiteral( "distanceThreshold" ), 0, QgsSettings::Gps ).toDouble();
mApplyLeapSettings = settings.value( QStringLiteral( "applyLeapSeconds" ), true, QgsSettings::Gps ).toBool();
mLeapSeconds = settings.value( QStringLiteral( "leapSecondsCorrection" ), 18, QgsSettings::Gps ).toInt();
acquisitionInterval = QgsGpsLogger::settingsAcquisitionInterval->value();
mDistanceThreshold = QgsGpsLogger::settingsDistanceThreshold->value();
mApplyLeapSettings = QgsGpsLogger::settingsApplyLeapSeconds->value();
mLeapSeconds = QgsGpsLogger::settingsLeapSecondsCorrection->value();

switch ( settings.value( QStringLiteral( "timeStampFormat" ), Qt::LocalTime, QgsSettings::Gps ).toInt() )
switch ( QgsGpsLogger::settingsTimeStampFormat->value() )
{
case 0:
mTimeStampSpec = Qt::TimeSpec::LocalTime;
Expand All @@ -244,7 +255,7 @@ void QgsGpsLogger::updateGpsSettings()
mTimeStampSpec = Qt::TimeSpec::TimeZone;
break;
}
mTimeZone = settings.value( QStringLiteral( "timestampTimeZone" ), QVariant(), QgsSettings::Gps ).toString();
mTimeZone = QgsGpsLogger::settingsTimestampTimeZone->value();
}

mAcquisitionInterval = acquisitionInterval * 1000;
Expand Down
19 changes: 18 additions & 1 deletion src/core/gps/qgsgpslogger.h
Expand Up @@ -31,10 +31,15 @@
#include <QDateTime>
#include "info.h"

class QgsSettingsEntryBool;
class QgsSettingsEntryString;
class QgsSettingsEntryInteger;
class QgsSettingsEntryDouble;
class QgsGpsConnection;
class QTimer;
class QgsGpsInformation;

class QTimer;


/**
* \ingroup core
Expand All @@ -52,6 +57,18 @@ class CORE_EXPORT QgsGpsLogger : public QObject

public:

static const QgsSettingsEntryBool *settingsApplyLeapSeconds SIP_SKIP;

static const QgsSettingsEntryString *settingsTimestampTimeZone SIP_SKIP;

static const QgsSettingsEntryInteger *settingsTimeStampFormat SIP_SKIP;

static const QgsSettingsEntryInteger *settingsLeapSecondsCorrection SIP_SKIP;

static const QgsSettingsEntryInteger *settingsAcquisitionInterval SIP_SKIP;

static const QgsSettingsEntryDouble *settingsDistanceThreshold SIP_SKIP;

#ifndef SIP_RUN
//! Settings entry for whether storing GPS attributes as geometry M values should be enabled
static const QgsSettingsEntryBool *settingsGpsStoreAttributeInMValues;
Expand Down

0 comments on commit 33368d7

Please sign in to comment.