Skip to content
Permalink
Browse files

Make geometry validation automatic resolutions experimental

The automatic resolutions work unreliably (mostly due to geometry precision) and
therefore cannot be use reliably. Therefore they should rather be treated as a
technology preview which can be opted into for the moment.
  • Loading branch information
m-kuhn committed Feb 27, 2019
1 parent 4e9c4b5 commit cd33ee7d5684b5dc9be8f76d888148f08194f160
@@ -116,6 +116,24 @@ Write the geometry options to the ``node``.
Read the geometry options from ``node``.

.. versionadded:: 3.4
%End

bool automaticProblemResolutionEnabled() const;
%Docstring
Automatic problem resolution offers strategies to fix errors with
a single click.
This is currently experimental

.. versionadded:: 3.8
%End

void setAutomaticProblemResolutionEnabled( bool automaticProblemResolutionEnabled );
%Docstring
Automatic problem resolution offers strategies to fix errors with
a single click.
This is currently experimental

.. versionadded:: 3.8
%End

signals:
@@ -148,6 +166,11 @@ Geometries which are edited on this layer will be rounded to multiples of this v
Set to 0.0 to disable.

.. versionadded:: 3.4
%End

void automaticProblemResolutionEnabledChanged();
%Docstring
Defines if the automatic fixes
%End

};
@@ -164,6 +164,14 @@ void QgsGeometryValidationDock::onRowsInserted()
setUserVisible( true );
}

void QgsGeometryValidationDock::updateResolutionWidgetVisibility()
{
if ( !mCurrentLayer )
return;

mResolutionWidget->setVisible( mCurrentLayer->geometryOptions()->automaticProblemResolutionEnabled() );
}

QgsGeometryValidationService *QgsGeometryValidationDock::geometryValidationService() const
{
return mGeometryValidationService;
@@ -275,6 +283,8 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
disconnect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
disconnect( mCurrentLayer->geometryOptions(), &QgsGeometryOptions::automaticProblemResolutionEnabledChanged, this, &QgsGeometryValidationDock::updateResolutionWidgetVisibility );
updateResolutionWidgetVisibility();
}

mCurrentLayer = qobject_cast<QgsVectorLayer *>( layer );
@@ -284,6 +294,7 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
connect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
connect( mCurrentLayer->geometryOptions(), &QgsGeometryOptions::automaticProblemResolutionEnabledChanged, this, &QgsGeometryValidationDock::updateResolutionWidgetVisibility );
}

onLayerEditingStatusChanged();
@@ -57,6 +57,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
void updateLayerTransform();
void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles );
void onRowsInserted();
void updateResolutionWidgetVisibility();

private:

@@ -463,12 +463,14 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
}
mTopologyChecksGroupBox->setLayout( topologyCheckLayout );
mTopologyChecksGroupBox->setVisible( !topologyCheckFactories.isEmpty() );
mAutomaticProblemResolutionCheckbox->setChecked( mLayer->geometryOptions()->automaticProblemResolutionEnabled() );
}
else
{
mRemoveDuplicateNodesCheckbox->setEnabled( false );
mGeometryPrecisionLineEdit->setEnabled( false );
mGeometryAutoFixesGroupBox->setEnabled( false );
mAutomaticProblemResolutionCheckbox->setEnabled( false );
}

mOptsPage_Information->setProperty( "helpPage", QStringLiteral( "working_with_vector/vector_properties.html#information-properties" ) );
@@ -839,6 +841,7 @@ void QgsVectorLayerProperties::apply()
activeChecks << it.value();
}
mLayer->geometryOptions()->setGeometryChecks( activeChecks );
mLayer->geometryOptions()->setAutomaticProblemResolutionEnabled( mAutomaticProblemResolutionCheckbox->isChecked() );

mLayer->triggerRepaint();
// notify the project we've made a change
@@ -115,3 +115,15 @@ void QgsGeometryOptions::readXml( const QDomNode &node )
const QVariant checkConfiguration = QgsXmlUtils::readVariant( checkConfigurationElem );
mCheckConfiguration = checkConfiguration.toMap();
}

bool QgsGeometryOptions::automaticProblemResolutionEnabled() const
{
return mAutomaticProblemResolutionEnabled;
}

void QgsGeometryOptions::setAutomaticProblemResolutionEnabled( bool automaticFixesEnabled )
{
if ( automaticFixesEnabled != mAutomaticProblemResolutionEnabled )
mAutomaticProblemResolutionEnabled = automaticFixesEnabled;
emit automaticProblemResolutionEnabledChanged();
}
@@ -131,6 +131,24 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
*/
void readXml( const QDomNode &node );

/**
* Automatic problem resolution offers strategies to fix errors with
* a single click.
* This is currently experimental
*
* \since QGIS 3.8
*/
bool automaticProblemResolutionEnabled() const;

/**
* Automatic problem resolution offers strategies to fix errors with
* a single click.
* This is currently experimental
*
* \since QGIS 3.8
*/
void setAutomaticProblemResolutionEnabled( bool automaticProblemResolutionEnabled );

signals:

/**
@@ -163,6 +181,11 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
*/
void geometryPrecisionChanged();

/**
* Defines if the automatic fixes
*/
void automaticProblemResolutionEnabledChanged();

private:

/**
@@ -183,6 +206,7 @@ class CORE_EXPORT QgsGeometryOptions : public QObject

QStringList mGeometryChecks;
QVariantMap mCheckConfiguration;
bool mAutomaticProblemResolutionEnabled = false;
};

#endif // QGSGEOMETRYOPTIONS_H
@@ -436,8 +436,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>804</height>
<width>315</width>
<height>403</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -724,8 +724,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>804</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
@@ -910,8 +910,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>804</height>
<width>113</width>
<height>110</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
@@ -1305,8 +1305,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>804</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@@ -1508,7 +1508,7 @@ border-radius: 2px;</string>
<x>0</x>
<y>0</y>
<width>734</width>
<height>790</height>
<height>372</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -1964,8 +1964,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>804</height>
<width>378</width>
<height>678</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -2439,6 +2439,16 @@ border-radius: 2px;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mAutomaticProblemResolutionCheckbox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This enables additional buttons for check results that will automatically fix problems.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Experimental&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This functionality is tagged as experimental since some of the automatic fixes do not work completely reliable.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Offer automatic problem resolution (Experimental)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">

0 comments on commit cd33ee7

Please sign in to comment.
You can’t perform that action at this time.