Skip to content

Commit

Permalink
[feature][gps] Add option to store selected GPS component in geometry
Browse files Browse the repository at this point in the history
M values

This new setting, available from the GPS settings panel, allows
users to opt into creating geometries with M values from the
inbuilt GPS logging tools. This applies to both features digitized
from GPS logs and from the new "Log to Geopackage/Spatialite"
functionality.

Options include storing timestamps (as ms since epoch), ground speed,
altitudes, bearings, and accuracy components as m values.

Sponsored by NIWA
  • Loading branch information
nyalldawson committed Dec 8, 2022
1 parent 2cecb3f commit 339ae1f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
29 changes: 29 additions & 0 deletions src/app/options/qgsgpsoptions.cpp
Expand Up @@ -131,6 +131,20 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
mCboAcquisitionInterval->setValidator( mAcquisitionIntValidator );
mCboDistanceThreshold->setValidator( mDistanceThresholdValidator );

mComboMValueAttribute->addItem( tr( "Do not Store M Values" ) );
mComboMValueAttribute->addItem( tr( "Timestamp (Milliseconds Since Epoch)" ), QVariant::fromValue( Qgis::GpsInformationComponent::Timestamp ) );
mComboMValueAttribute->addItem( tr( "Ground Speed" ), QVariant::fromValue( Qgis::GpsInformationComponent::GroundSpeed ) );
mComboMValueAttribute->addItem( tr( "Bearing" ), QVariant::fromValue( Qgis::GpsInformationComponent::Bearing ) );
mComboMValueAttribute->addItem( tr( "Altitude (Geoid)" ), QVariant::fromValue( Qgis::GpsInformationComponent::EllipsoidAltitude ) );
mComboMValueAttribute->addItem( tr( "Altitude (WGS-84 Ellipsoid)" ), QVariant::fromValue( Qgis::GpsInformationComponent::Altitude ) );
mComboMValueAttribute->addItem( tr( "PDOP" ), QVariant::fromValue( Qgis::GpsInformationComponent::Pdop ) );
mComboMValueAttribute->addItem( tr( "HDOP" ), QVariant::fromValue( Qgis::GpsInformationComponent::Hdop ) );
mComboMValueAttribute->addItem( tr( "VDOP" ), QVariant::fromValue( Qgis::GpsInformationComponent::Vdop ) );
mComboMValueAttribute->addItem( tr( "Horizontal Accuracy" ), QVariant::fromValue( Qgis::GpsInformationComponent::HorizontalAccuracy ) );
mComboMValueAttribute->addItem( tr( "Vertical Accuracy" ), QVariant::fromValue( Qgis::GpsInformationComponent::VerticalAccuracy ) );
mComboMValueAttribute->addItem( tr( "Accuracy (3D RMS)" ), QVariant::fromValue( Qgis::GpsInformationComponent::HvAccuracy ) );
mComboMValueAttribute->addItem( tr( "Satellites Used" ), QVariant::fromValue( Qgis::GpsInformationComponent::SatellitesUsed ) );
mComboMValueAttribute->setCurrentIndex( 0 );

Qgis::GpsConnectionType connectionType = Qgis::GpsConnectionType::Automatic;
QString gpsdHost;
Expand Down Expand Up @@ -163,6 +177,11 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
timeSpec = QgsGpsConnection::settingsGpsTimeStampSpecification.value();
timeZone = QgsGpsConnection::settingsGpsTimeStampTimeZone.value();
offsetFromUtc = static_cast< int >( QgsGpsConnection::settingsGpsTimeStampOffsetFromUtc.value() );

if ( QgsGpsLogger::settingsGpsStoreAttributeInMValues.value() )
{
mComboMValueAttribute->setCurrentIndex( mComboMValueAttribute->findData( QVariant::fromValue( QgsGpsLogger::settingsGpsMValueComponent.value() ) ) );
}
}
else
{
Expand Down Expand Up @@ -354,6 +373,16 @@ void QgsGpsOptionsWidget::apply()
QgsGpsConnection::settingGpsApplyLeapSecondsCorrection.setValue( mCbxLeapSeconds->isChecked() );
QgsGpsConnection::settingGpsLeapSeconds.setValue( mLeapSeconds->value() );
QgsGpsConnection::settingsGpsTimeStampOffsetFromUtc.setValue( mOffsetFromUtc->value() );

if ( !mComboMValueAttribute->currentData().isValid() )
{
QgsGpsLogger::settingsGpsStoreAttributeInMValues.setValue( false );
}
else
{
QgsGpsLogger::settingsGpsStoreAttributeInMValues.setValue( true );
QgsGpsLogger::settingsGpsMValueComponent.setValue( mComboMValueAttribute->currentData().value< Qgis::GpsInformationComponent >() );
}
}

void QgsGpsOptionsWidget::refreshDevices()
Expand Down
30 changes: 25 additions & 5 deletions src/ui/qgsgpsoptionswidgetbase.ui
Expand Up @@ -261,6 +261,25 @@
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox_5">
<property name="title">
<string>Geometry Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_5" columnstretch="1,2">
<item row="0" column="1">
<widget class="QComboBox" name="mComboMValueAttribute"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Store in M values</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox_2">
<property name="title">
Expand Down Expand Up @@ -567,17 +586,18 @@
</customwidgets>
<tabstops>
<tabstop>scrollArea</tabstop>
<tabstop>mRadAutodetect</tabstop>
<tabstop>mRadInternal</tabstop>
<tabstop>mRadSerialDevice</tabstop>
<tabstop>mCboDevices</tabstop>
<tabstop>mBtnRefreshDevices</tabstop>
<tabstop>mRadAutodetect</tabstop>
<tabstop>mGpsdDevice</tabstop>
<tabstop>mRadGpsd</tabstop>
<tabstop>mGpsdHost</tabstop>
<tabstop>mSpinGpsdPort</tabstop>
<tabstop>mRadGpsd</tabstop>
<tabstop>mRadSerialDevice</tabstop>
<tabstop>mCboDistanceThreshold</tabstop>
<tabstop>mGpsdDevice</tabstop>
<tabstop>mCboAcquisitionInterval</tabstop>
<tabstop>mCboDistanceThreshold</tabstop>
<tabstop>mComboMValueAttribute</tabstop>
<tabstop>mGpsMarkerSymbolButton</tabstop>
<tabstop>mCheckRotateLocationMarker</tabstop>
<tabstop>mBearingLineStyleButton</tabstop>
Expand Down

0 comments on commit 339ae1f

Please sign in to comment.