Skip to content
Permalink
Browse files

Merge pull request #8103 from m-kuhn/geometryValidatorCode_1

Geometry validation of editing session
  • Loading branch information
m-kuhn committed Oct 16, 2018
2 parents ee8e1ce + 6c97fcf commit 190f93865433c8d747a301f07ce7f42ec6b57521
Showing with 2,698 additions and 263 deletions.
  1. +8 −0 python/analysis/auto_generated/vector/geometry_checker/qgsfeaturepool.sip.in
  2. +11 −16 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in
  3. +5 −7 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip.in
  4. +7 −6 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerutils.sip.in
  5. +10 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckfactory.sip.in
  6. +4 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckregistry.sip.in
  7. +8 −0 python/analysis/auto_generated/vector/geometry_checker/qgssinglegeometrycheck.sip.in
  8. +62 −1 python/core/auto_generated/qgsgeometryoptions.sip.in
  9. +1 −1 python/core/core_auto.sip
  10. +3 −4 src/analysis/CMakeLists.txt
  11. +22 −0 src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
  12. +20 −0 src/analysis/vector/geometry_checker/qgsfeaturepool.h
  13. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h
  14. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryareacheck.h
  15. +11 −3 src/analysis/vector/geometry_checker/qgsgeometrycheck.h
  16. +1 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.h
  17. +7 −1 src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h
  18. +2 −2 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.cpp
  19. +9 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.h
  20. +5 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckfactory.h
  21. +1 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckregistry.h
  22. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h
  23. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h
  24. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h
  25. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h
  26. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h
  27. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h
  28. +28 −16 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
  29. +18 −4 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
  30. +1 −1 src/analysis/vector/geometry_checker/qgsgeometryholecheck.h
  31. +17 −1 src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.cpp
  32. +11 −0 src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.h
  33. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h
  34. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h
  35. +50 −9 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp
  36. +7 −3 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h
  37. +16 −12 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp
  38. +36 −6 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h
  39. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h
  40. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h
  41. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h
  42. +2 −0 src/analysis/vector/geometry_checker/qgssinglegeometrycheck.h
  43. +22 −20 src/analysis/vector/geometry_checker/qgsvectorlayerfeaturepool.cpp
  44. +7 −1 src/analysis/vector/geometry_checker/qgsvectorlayerfeaturepool.h
  45. +8 −0 src/app/CMakeLists.txt
  46. +29 −2 src/app/qgisapp.cpp
  47. +8 −0 src/app/qgisapp.h
  48. +351 −0 src/app/qgsgeometryvalidationdock.cpp
  49. +85 −0 src/app/qgsgeometryvalidationdock.h
  50. +391 −0 src/app/qgsgeometryvalidationmodel.cpp
  51. +90 −0 src/app/qgsgeometryvalidationmodel.h
  52. +460 −0 src/app/qgsgeometryvalidationservice.cpp
  53. +127 −0 src/app/qgsgeometryvalidationservice.h
  54. +1 −0 src/app/qgsmaplayerstylecategoriesmodel.cpp
  55. +43 −5 src/app/qgsvectorlayerproperties.cpp
  56. +2 −0 src/app/qgsvectorlayerproperties.h
  57. +1 −1 src/app/vertextool/qgsvertextool.cpp
  58. +1 −1 src/core/CMakeLists.txt
  59. +41 −1 src/core/qgsgeometryoptions.cpp
  60. +68 −1 src/core/qgsgeometryoptions.h
  61. +1 −18 src/gui/qgsmaptoolcapture.cpp
  62. +1 −4 src/gui/qgsmaptoolcapture.h
  63. +3 −0 src/gui/qgsrubberband.cpp
  64. +1 −1 src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp
  65. +1 −1 src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
  66. +204 −0 src/ui/qgsgeometryvalidationdockbase.ui
  67. +90 −66 src/ui/qgsvectorlayerpropertiesbase.ui
  68. +18 −14 tests/src/geometry_checker/CMakeLists.txt
  69. +77 −21 tests/src/geometry_checker/testqgsgeometrychecks.cpp
  70. +171 −0 tests/src/geometry_checker/testqgsvectorlayerfeaturepool.cpp
@@ -15,6 +15,12 @@ class QgsFeaturePool : QgsFeatureSink /Abstract/
{
%Docstring
A feature pool is based on a vector layer and caches features.

.. note::

This class is a technology preview and unstable API.

.. versionadded:: 3.4
%End

%TypeHeaderCode
@@ -31,6 +37,7 @@ It will be retrieved from the cache or from the underlying layer if unavailable.
If the feature is neither available from the cache nor from the layer it will return false.
%End


virtual void updateFeature( QgsFeature &feature ) = 0;
%Docstring
Updates a feature in this pool.
@@ -89,6 +96,7 @@ To be used by implementations of ``deleteFeature``.
%End



private:
QgsFeaturePool( const QgsFeaturePool &other );
};
@@ -10,24 +10,19 @@




class QgsGeometryCheck
{
%Docstring
*************************************************************************
qgsgeometrycheck.h
---------------------
begin : September 2014
copyright : (C) 2014 by Sandro Mani / Sourcepole AG
email : smani at sourcepole dot ch
**************************************************************************

This program is free software; you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or *
(at your option) any later version. *

**************************************************************************
This class manages all known geometry check factories.

QgsGeometryCheckRegistry is not usually directly created, but rather accessed through
:py:func:`QgsAnalysis.geometryCheckRegistry()`

.. note::

This class is a technology preview and unstable API.

.. versionadded:: 3.4
%End

%TypeHeaderCode
@@ -120,7 +115,7 @@ A list of geometry types for which this check can be performed.
Flags for this geometry check.
%End

virtual void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors /In,Out/, QStringList &messages /In,Out/, QgsFeedback *feedback = 0, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0;
virtual void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors /In,Out/, QStringList &messages /In,Out/, QgsFeedback *feedback, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0;
%Docstring
The main worker method.
Check all features available from ``featurePools`` and write errors found to ``errors``.
@@ -11,18 +11,16 @@




class QgsGeometryCheckError
{
%Docstring
*************************************************************************
This represents an error reported by a geometry check.

.. note::

This program is free software; you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or *
(at your option) any later version. *
This class is a technology preview and unstable API.

**************************************************************************
.. versionadded:: 3.4
%End

%TypeHeaderCode
@@ -10,17 +10,18 @@




class QgsGeometryCheckerUtils
{
%Docstring
*************************************************************************

This program is free software; you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or *
(at your option) any later version. *
Contains utilities required for geometry checks.

.. note::

This class is a technology preview and unstable API.

**************************************************************************
.. versionadded:: 3.4
%End

%TypeHeaderCode
@@ -14,6 +14,16 @@

class QgsGeometryCheckFactory /Abstract/
{
%Docstring

A factory for geometry checks.

.. note::

This class is a technology preview and unstable API.

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsgeometrycheckfactory.h"
@@ -19,6 +19,10 @@ This class manages all known geometry check factories.
QgsGeometryCheckRegistry is not usually directly created, but rather accessed through
:py:func:`QgsAnalysis.geometryCheckRegistry()`

.. note::

This class is a technology preview and unstable API.

.. versionadded:: 3.4
%End

@@ -17,6 +17,10 @@ class QgsSingleGeometryCheckError

An error from a QgsSingleGeometryCheck.

.. note::

This class is a technology preview and unstable API.

.. versionadded:: 3.4
%End

@@ -78,6 +82,10 @@ class QgsGeometryCheckErrorSingle : QgsGeometryCheckError
Wraps a QgsSingleGeometryError into a standard :py:class:`QgsGeometryCheckError`.
The single error can be obtained via singleError.

.. note::

This class is a technology preview and unstable API.

.. versionadded:: 3.4
%End

@@ -9,7 +9,8 @@



class QgsGeometryOptions

class QgsGeometryOptions : QObject
{
%Docstring

@@ -72,6 +73,34 @@ Determines if at least one fix is enabled.
%Docstring
Apply any fixes configured on this class to ``geometry``.

.. versionadded:: 3.4
%End

QStringList geometryChecks() const;
%Docstring
A list of activated geometry checks.

.. versionadded:: 3.4
%End

void setGeometryChecks( const QStringList &geometryChecks );
%Docstring
A list of activated geometry checks.

.. versionadded:: 3.4
%End

QVariantMap checkConfiguration( const QString &checkId ) const;
%Docstring
Access the configuration for the check ``checkId``.

.. versionadded:: 3.4
%End

void setCheckConfiguration( const QString &checkId, const QVariantMap &checkConfiguration );
%Docstring
Set the configuration for the check ``checkId``.

.. versionadded:: 3.4
%End

@@ -86,6 +115,38 @@ Write the geometry options to the ``node``.
%Docstring
Read the geometry options from ``node``.

.. versionadded:: 3.4
%End

signals:

void checkConfigurationChanged();
%Docstring
Access the configuration for the check ``checkId``.

.. versionadded:: 3.4
%End

void geometryChecksChanged();
%Docstring
A list of activated geometry checks.

.. versionadded:: 3.4
%End

void removeDuplicateNodesChanged();
%Docstring
Automatically remove duplicate nodes on all geometries which are edited on this layer.

.. versionadded:: 3.4
%End

void geometryPrecisionChanged();
%Docstring
The precision in which geometries on this layer should be saved.
Geometries which are edited on this layer will be rounded to multiples of this value (snap to grid).
Set to 0.0 to disable.

.. versionadded:: 3.4
%End

@@ -54,7 +54,6 @@
%Include auto_generated/qgsfields.sip
%Include auto_generated/qgsfileutils.sip
%Include auto_generated/qgsfontutils.sip
%Include auto_generated/qgsgeometryoptions.sip
%Include auto_generated/qgsgeometrysimplifier.sip
%Include auto_generated/qgshistogram.sip
%Include auto_generated/qgshstoreutils.sip
@@ -327,6 +326,7 @@
%Include auto_generated/qgsfieldproxymodel.sip
%Include auto_generated/qgsfiledownloader.sip
%Include auto_generated/qgsfeaturefiltermodel.sip
%Include auto_generated/qgsgeometryoptions.sip
%Include auto_generated/qgsgeometryvalidator.sip
%Include auto_generated/qgsgml.sip
%Include auto_generated/qgsgmlschema.sip
@@ -152,7 +152,6 @@ SET(QGIS_ANALYSIS_SRCS
vector/geometry_checker/qgsgeometryduplicatecheck.cpp
vector/geometry_checker/qgsgeometryduplicatenodescheck.cpp
vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp
vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp
vector/geometry_checker/qgsgeometrygapcheck.cpp
vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp
vector/geometry_checker/qgsgeometryholecheck.cpp
@@ -186,6 +185,9 @@ SET(QGIS_ANALYSIS_MOC_HDRS

vector/geometry_checker/qgsgeometrychecker.h
vector/geometry_checker/qgsgeometrycheck.h
vector/geometry_checker/qgsvectorlayerfeaturepool.h
vector/geometry_checker/qgsgeometrygapcheck.h
vector/geometry_checker/qgsgeometrymissingvertexcheck.h
)

INCLUDE_DIRECTORIES(SYSTEM ${SPATIALITE_INCLUDE_DIR})
@@ -252,7 +254,6 @@ SET(QGIS_ANALYSIS_HDRS
vector/geometry_checker/qgsgeometrycheckerutils.h
vector/geometry_checker/qgsfeaturepool.h
vector/geometry_checker/qgsvectordataproviderfeaturepool.h
vector/geometry_checker/qgsvectorlayerfeaturepool.h

interpolation/qgsinterpolator.h
interpolation/qgsgridfilewriter.h
@@ -292,8 +293,6 @@ SET(QGIS_ANALYSIS_HDRS
vector/geometry_checker/qgsgeometryduplicatecheck.h
vector/geometry_checker/qgsgeometryduplicatenodescheck.h
vector/geometry_checker/qgsgeometryfollowboundariescheck.h
vector/geometry_checker/qgsgeometrygapcheck.h
vector/geometry_checker/qgsgeometrymissingvertexcheck.h
vector/geometry_checker/qgsgeometryholecheck.h
vector/geometry_checker/qgsgeometrylineintersectioncheck.h
vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h
@@ -62,6 +62,23 @@ bool QgsFeaturePool::getFeature( QgsFeatureId id, QgsFeature &feature )
return true;
}

QgsFeatureIds QgsFeaturePool::getFeatures( const QgsFeatureRequest &request )
{
QgsFeatureIds fids;

std::unique_ptr<QgsVectorLayerFeatureSource> source = QgsVectorLayerUtils::getFeatureSource( mLayer );

QgsFeatureIterator it = source->getFeatures( request );
QgsFeature feature;
while ( it.nextFeature( feature ) )
{
insertFeature( feature );
fids << feature.id();
}

return fids;
}

QgsFeatureIds QgsFeaturePool::allFeatureIds() const
{
return mFeatureIds;
@@ -123,6 +140,11 @@ void QgsFeaturePool::setFeatureIds( const QgsFeatureIds &ids )
mFeatureIds = ids;
}

bool QgsFeaturePool::isFeatureCached( QgsFeatureId fid )
{
return mFeatureCache.contains( fid );
}

QgsCoordinateReferenceSystem QgsFeaturePool::crs() const
{
return mCrs;
@@ -31,6 +31,9 @@ class QgsVectorLayer;
/**
* \ingroup analysis
* A feature pool is based on a vector layer and caches features.
*
* \note This class is a technology preview and unstable API.
* \since QGIS 3.4
*/
class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
{
@@ -46,6 +49,15 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
*/
bool getFeature( QgsFeatureId id, QgsFeature &feature );

/**
* Get features for the provided \a request. No features will be fetched
* from the cache and the request is sent directly to the underlying feature source.
* Results of the request are cached in the pool and the ids of all the features
* are returned. This can be used to warm the cache for a particular area of interest
* (bounding box) or other set of features.
*/
QgsFeatureIds getFeatures( const QgsFeatureRequest &request ) SIP_SKIP;

/**
* Updates a feature in this pool.
* Implementations will update the feature on the layer or on the data provider.
@@ -136,6 +148,14 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
*/
void setFeatureIds( const QgsFeatureIds &ids ) SIP_SKIP;

/**
* Checks if the feature \a fid is cached.
*
* \note not available in Python bindings
* \since QGIS 3.4
*/
bool isFeatureCached( QgsFeatureId fid ) SIP_SKIP;

private:
#ifdef SIP_RUN
QgsFeaturePool( const QgsFeaturePool &other )
@@ -34,7 +34,7 @@ class ANALYSIS_EXPORT QgsGeometryAngleCheck : public QgsGeometryCheck
, mMinAngle( configuration.value( QStringLiteral( "minAngle" ), 0.0 ).toDouble() )
{}

void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;

QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override;

0 comments on commit 190f938

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