Skip to content

Commit

Permalink
Add global setting to control the display of CRS inaccuracy warnings
Browse files Browse the repository at this point in the history
This new setting in the Options -> CRS tab specifies a threshold
in meters, where CRS accuracy warnings will only be shown for
inaccuracies which exceed this distance.

This allows users who work in fields where lower accuracies are
acceptable to hide the CRS inaccuracy warnings when an ensemble datum
based CRS (such as 4326, 3857) is selected.
  • Loading branch information
nyalldawson committed May 11, 2021
1 parent b81ece4 commit 26a09f6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
5 changes: 5 additions & 0 deletions resources/qgis_global_settings.ini
Expand Up @@ -86,6 +86,11 @@ projections\newProjectCrsBehavior=UseCrsOfFirstLayerAdded
# "UseDefaultCrs" - use the default layer CRS set via QGIS options
projections\unknownCrsBehavior=NoAction

# If the inherent inaccuracy in a selected CRS exceeds this threshold value (in meters),
# a warning message will be shown to the user advising them to select an alternative
# CRS if higher positional accuracy is required
projections\crsAccuracyWarningThreshold=0.0

# Specifies a manual bearing correction to apply to bearings reported by a GPS
# device, for use when a map canvas is set to match rotation to the GPS bearing
# or when showing the GPS bearing line
Expand Down
6 changes: 6 additions & 0 deletions src/app/options/qgsoptions.cpp
Expand Up @@ -522,6 +522,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
break;
}

const double crsAccuracyWarningThreshold = mSettings->value( QStringLiteral( "/projections/crsAccuracyWarningThreshold" ), 0.0, QgsSettings::App ).toDouble();
mCrsAccuracySpin->setMinimumWidth( QFontMetrics( font() ).horizontalAdvance( '0' ) * 20 );
mCrsAccuracySpin->setClearValue( 0.0, tr( "Always show" ) );
mCrsAccuracySpin->setValue( crsAccuracyWarningThreshold );

mShowDatumTransformDialogCheckBox->setChecked( mSettings->value( QStringLiteral( "/projections/promptWhenMultipleTransformsExist" ), false, QgsSettings::App ).toBool() );

// Datum transforms
Expand Down Expand Up @@ -1700,6 +1705,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( QStringLiteral( "/projections/defaultProjectCrs" ), leProjectGlobalCrs->crs().authid(), QgsSettings::App );
mSettings->setEnumValue( QStringLiteral( "/projections/newProjectCrsBehavior" ), radProjectUseCrsOfFirstLayer->isChecked() ? QgsGui::UseCrsOfFirstLayerAdded : QgsGui::UsePresetCrs, QgsSettings::App );
mSettings->setValue( QStringLiteral( "/projections/promptWhenMultipleTransformsExist" ), mShowDatumTransformDialogCheckBox->isChecked(), QgsSettings::App );
mSettings->setValue( QStringLiteral( "/projections/crsAccuracyWarningThreshold" ), mCrsAccuracySpin->value(), QgsSettings::App );

//measurement settings
mSettings->setValue( QStringLiteral( "measure/planimetric" ), mPlanimetricMeasurementsComboBox->isChecked(), QgsSettings::Core );
Expand Down
4 changes: 3 additions & 1 deletion src/gui/qgsprojectionselectionwidget.cpp
Expand Up @@ -366,8 +366,10 @@ void QgsProjectionSelectionWidget::updateWarning()

try
{
const double crsAccuracyWarningThreshold = QgsSettings().value( QStringLiteral( "/projections/crsAccuracyWarningThreshold" ), 0.0, QgsSettings::App ).toDouble();

const QgsDatumEnsemble ensemble = crs().datumEnsemble();
if ( !ensemble.isValid() || ensemble.name() == mSourceEnsemble )
if ( !ensemble.isValid() || ensemble.name() == mSourceEnsemble || ( ensemble.accuracy() > 0 && ensemble.accuracy() < crsAccuracyWarningThreshold ) )
{
mWarningLabelContainer->hide();
}
Expand Down
48 changes: 45 additions & 3 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -1760,6 +1760,13 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mPlanimetricMeasurementsComboBox">
<property name="text">
<string>Planimetric measurements</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down Expand Up @@ -1825,10 +1832,45 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="mPlanimetricMeasurementsComboBox">
<property name="text">
<string>Planimetric measurements</string>
<widget class="QgsCollapsibleGroupBox" name="groupBox_26">
<property name="title">
<string>Accuracy Warnings</string>
</property>
<layout class="QGridLayout" name="gridLayout_37" columnstretch="0,1,2">
<item row="0" column="1">
<widget class="QgsDoubleSpinBox" name="mCrsAccuracySpin">
<property name="toolTip">
<string>If the inherent inaccuracy in a selected CRS exceeds this threshold a warning message will be shown</string>
</property>
<property name="suffix">
<string> meters</string>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_71">
<property name="text">
<string>Only show CRS accuracy warnings for inaccuracies which exceed</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_23">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 26a09f6

Please sign in to comment.