From 6a9403348741321453b656392ae9ba09cf3c2ee0 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 1 Oct 2018 15:00:16 +0200 Subject: [PATCH] Make feedback a required parameter for geometry checks --- .../geometry_checker/qgsgeometrycheck.sip.in | 2 +- .../geometry_checker/qgsgeometryanglecheck.h | 2 +- .../geometry_checker/qgsgeometryareacheck.h | 2 +- .../geometry_checker/qgsgeometrycheck.h | 2 +- .../qgsgeometrycontainedcheck.h | 2 +- .../geometry_checker/qgsgeometrydanglecheck.h | 2 +- .../qgsgeometrydegeneratepolygoncheck.h | 2 +- .../qgsgeometryduplicatecheck.h | 2 +- .../qgsgeometryduplicatenodescheck.h | 2 +- .../qgsgeometryfollowboundariescheck.h | 2 +- .../geometry_checker/qgsgeometrygapcheck.h | 2 +- .../geometry_checker/qgsgeometryholecheck.h | 2 +- .../qgsgeometrylineintersectioncheck.h | 2 +- .../qgsgeometrylinelayerintersectioncheck.h | 2 +- .../qgsgeometrymissingvertexcheck.h | 2 +- .../qgsgeometryoverlapcheck.h | 2 +- .../qgsgeometrypointcoveredbylinecheck.h | 2 +- .../qgsgeometrypointinpolygoncheck.h | 2 +- .../qgsgeometrysegmentlengthcheck.h | 2 +- .../testqgsgeometrychecks.cpp | 72 ++++++++++++------- 20 files changed, 67 insertions(+), 43 deletions(-) diff --git a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in index 365ea55e4b6d..a307de05503f 100644 --- a/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in +++ b/python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in @@ -120,7 +120,7 @@ A list of geometry types for which this check can be performed. Flags for this geometry check. %End - virtual void collectErrors( const QMap &featurePools, QList &errors /In,Out/, QStringList &messages /In,Out/, QgsFeedback *feedback = 0, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0; + virtual void collectErrors( const QMap &featurePools, QList &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``. diff --git a/src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h b/src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h index d9eb54b765bb..d334881ef077 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h @@ -34,7 +34,7 @@ class ANALYSIS_EXPORT QgsGeometryAngleCheck : public QgsGeometryCheck , mMinAngle( configuration.value( QStringLiteral( "minAngle" ), 0.0 ).toDouble() ) {} - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QList compatibleGeometryTypes() const override; diff --git a/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h b/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h index 18da59f1d6fd..2224cde8e154 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h @@ -32,7 +32,7 @@ class ANALYSIS_EXPORT QgsGeometryAreaCheck : public QgsGeometryCheck , mAreaThreshold( configurationValue( "areaThreshold" ) ) {} QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; QString id() const override { return factoryId(); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycheck.h b/src/analysis/vector/geometry_checker/qgsgeometrycheck.h index 20d1ace05be2..ffa2c01e0513 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrycheck.h @@ -200,7 +200,7 @@ class ANALYSIS_EXPORT QgsGeometryCheck * * \since QGIS 3.4 */ - virtual void collectErrors( const QMap &featurePools, QList &errors SIP_INOUT, QStringList &messages SIP_INOUT, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0; + virtual void collectErrors( const QMap &featurePools, QList &errors SIP_INOUT, QStringList &messages SIP_INOUT, QgsFeedback *feedback, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0; /** * Fix the error \a error with the specified \a method. diff --git a/src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h b/src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h index e0f162b5797f..25965004ca4f 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h @@ -57,7 +57,7 @@ class ANALYSIS_EXPORT QgsGeometryContainedCheck : public QgsGeometryCheck explicit QgsGeometryContainedCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration ) : QgsGeometryCheck( context, configuration ) {} QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; QString id() const override { return factoryId(); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h b/src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h index 31f0d12dd25f..bd537f083187 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h @@ -29,7 +29,7 @@ class ANALYSIS_EXPORT QgsGeometryDangleCheck : public QgsGeometryCheck void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; QStringList resolutionMethods() const override; QString description() const override { return factoryDescription(); } QString id() const override { return factoryId(); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h b/src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h index 741201a2a01a..e5f1cfe8d03b 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h @@ -28,7 +28,7 @@ class ANALYSIS_EXPORT QgsGeometryDegeneratePolygonCheck : public QgsGeometryChec explicit QgsGeometryDegeneratePolygonCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration ) : QgsGeometryCheck( context, configuration ) {} - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h b/src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h index 031340af50e3..a8741ddf4b0c 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h @@ -55,7 +55,7 @@ class ANALYSIS_EXPORT QgsGeometryDuplicateCheck : public QgsGeometryCheck public: explicit QgsGeometryDuplicateCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration ) : QgsGeometryCheck( context, configuration ) {} - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h b/src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h index e969d8ba38b1..f88a4dee4b26 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h @@ -28,7 +28,7 @@ class ANALYSIS_EXPORT QgsGeometryDuplicateNodesCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::LineGeometry, QgsWkbTypes::PolygonGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Duplicate node" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h b/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h index ca815181949b..d6fa8278b395 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h @@ -31,7 +31,7 @@ class ANALYSIS_EXPORT QgsGeometryFollowBoundariesCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PolygonGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Polygon does not follow boundaries" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h index 32dc0b5e707e..5aa9255bbb4f 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h @@ -87,7 +87,7 @@ class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck explicit QgsGeometryGapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration ); QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; diff --git a/src/analysis/vector/geometry_checker/qgsgeometryholecheck.h b/src/analysis/vector/geometry_checker/qgsgeometryholecheck.h index 6d4ffe0a5641..b216c16a3352 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryholecheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryholecheck.h @@ -28,7 +28,7 @@ class ANALYSIS_EXPORT QgsGeometryHoleCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PolygonGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Polygon with hole" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h b/src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h index c0b51473a27c..4cf7db54541f 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h @@ -29,7 +29,7 @@ class ANALYSIS_EXPORT QgsGeometryLineIntersectionCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::LineGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Intersection" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h b/src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h index 23ac44a917d4..6bb5614a50db 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h @@ -30,7 +30,7 @@ class ANALYSIS_EXPORT QgsGeometryLineLayerIntersectionCheck : public QgsGeometry static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::LineGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Intersection" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h b/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h index 9b020ce32264..2dd53aa29e34 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h @@ -42,7 +42,7 @@ class ANALYSIS_EXPORT QgsGeometryMissingVertexCheck : public QgsGeometryCheck }; explicit QgsGeometryMissingVertexCheck( const QgsGeometryCheckContext *context, const QVariantMap &geometryCheckConfiguration ); - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; diff --git a/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h b/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h index 252e54aef638..1e5b79b1eda4 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h @@ -85,7 +85,7 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheck : public QgsGeometryCheck */ QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration ); QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; diff --git a/src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h b/src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h index bd38356e1f2d..8726f80c42e9 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h @@ -29,7 +29,7 @@ class ANALYSIS_EXPORT QgsGeometryPointCoveredByLineCheck : public QgsGeometryChe static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PointGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Point not covered by line" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h b/src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h index 9f073de8b6a0..cf6cef83bcbe 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h @@ -29,7 +29,7 @@ class ANALYSIS_EXPORT QgsGeometryPointInPolygonCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PointGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Point not in polygon" ); } diff --git a/src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h b/src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h index 33c188f7d82a..8a62bb02ed78 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h @@ -30,7 +30,7 @@ class ANALYSIS_EXPORT QgsGeometrySegmentLengthCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {QgsWkbTypes::LineGeometry, QgsWkbTypes::PolygonGeometry}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } QList compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); } - void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; + void collectErrors( const QMap &featurePools, QList &errors, QStringList &messages, QgsFeedback *feedback, const LayerFeatureIds &ids = LayerFeatureIds() ) const override; void fixError( const QMap &featurePools, QgsGeometryCheckError *error, int method, const QMap &mergeAttributeIndices, Changes &changes ) const override; QStringList resolutionMethods() const override; static QString factoryDescription() { return tr( "Minimal segment length" ); } diff --git a/tests/src/geometry_checker/testqgsgeometrychecks.cpp b/tests/src/geometry_checker/testqgsgeometrychecks.cpp index f5683ddbbf9a..6cb20a6cf208 100644 --- a/tests/src/geometry_checker/testqgsgeometrychecks.cpp +++ b/tests/src/geometry_checker/testqgsgeometrychecks.cpp @@ -41,6 +41,7 @@ #include "qgsgeometrysliverpolygoncheck.h" #include "qgsvectordataproviderfeaturepool.h" #include "qgsproject.h" +#include "qgsfeedback.h" #include "qgsgeometrytypecheck.h" @@ -88,6 +89,7 @@ class TestQgsGeometryChecks: public QObject void testLineLayerIntersectionCheck(); void testMultipartCheck(); void testOverlapCheck(); + void testOverlapCheckNoMaxArea(); void testPointCoveredByLineCheck(); void testPointInPolygonCheck(); void testSegmentLengthCheck(); @@ -125,7 +127,8 @@ void TestQgsGeometryChecks::testAngleCheck() configuration.insert( "minAngle", 15 ); QgsGeometryAngleCheck check( testContext.first, configuration ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -203,7 +206,8 @@ void TestQgsGeometryChecks::testAreaCheck() configuration.insert( "areaThreshold", 0.04 ); QgsGeometryAreaCheck check( testContext.first, configuration ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -295,7 +299,8 @@ void TestQgsGeometryChecks::testContainedCheck() QStringList messages; QgsGeometryContainedCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -332,7 +337,8 @@ void TestQgsGeometryChecks::testDangleCheck() QStringList messages; QgsGeometryDangleCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -369,7 +375,8 @@ void TestQgsGeometryChecks::testDegeneratePolygonCheck() QStringList messages; QgsGeometryDegeneratePolygonCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -404,7 +411,8 @@ void TestQgsGeometryChecks::testDuplicateCheck() QStringList messages; QgsGeometryDuplicateCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -448,7 +456,8 @@ void TestQgsGeometryChecks::testDuplicateNodesCheck() QStringList messages; QgsGeometryDuplicateNodesCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -487,7 +496,8 @@ void TestQgsGeometryChecks::testFollowBoundariesCheck() QList checkErrors; QStringList messages; - QgsGeometryFollowBoundariesCheck( testContext.first, QVariantMap(), testContext.second[layers["follow_ref.shp"]]->layer() ).collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + QgsGeometryFollowBoundariesCheck( testContext.first, QVariantMap(), testContext.second[layers["follow_ref.shp"]]->layer() ).collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QCOMPARE( checkErrors.size(), 2 ); @@ -512,7 +522,8 @@ void TestQgsGeometryChecks::testGapCheck() configuration.insert( "gapThreshold", 0.01 ); QgsGeometryGapCheck check( testContext.first, configuration ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -553,7 +564,8 @@ void TestQgsGeometryChecks::testMissingVertexCheck() QStringList messages; QgsGeometryMissingVertexCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); const QString layerId = testContext.second.first()->layerId(); @@ -582,7 +594,8 @@ void TestQgsGeometryChecks::testHoleCheck() QStringList messages; QgsGeometryHoleCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -620,7 +633,8 @@ void TestQgsGeometryChecks::testLineIntersectionCheck() QStringList messages; QgsGeometryLineIntersectionCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QCOMPARE( checkErrors.size(), 1 ); @@ -648,7 +662,8 @@ void TestQgsGeometryChecks::testLineLayerIntersectionCheck() configuration.insert( "checkLayer", layers["polygon_layer.shp"] ); QgsGeometryLineLayerIntersectionCheck check( testContext.first, configuration ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QCOMPARE( checkErrors.size(), 5 ); @@ -677,7 +692,8 @@ void TestQgsGeometryChecks::testMultipartCheck() QStringList messages; QgsGeometryMultipartCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QVERIFY( searchCheckErrors( checkErrors, layers["point_layer.shp"] ).isEmpty() ); @@ -728,6 +744,7 @@ void TestQgsGeometryChecks::testOverlapCheck() layers.insert( "point_layer.shp", "" ); layers.insert( "line_layer.shp", "" ); layers.insert( "polygon_layer.shp", "" ); + auto testContext = createTestContext( dir, layers ); // Test detection @@ -738,7 +755,8 @@ void TestQgsGeometryChecks::testOverlapCheck() configuration.insert( "maxOverlapArea", 0.01 ); QgsGeometryOverlapCheck check( testContext.first, configuration ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -769,9 +787,9 @@ void TestQgsGeometryChecks::testOverlapCheckNoMaxArea() { QTemporaryDir dir; QMap layers; - layers.insert( QStringLiteral("point_layer.shp"), QString() ); - layers.insert( QStringLiteral("line_layer.shp"), QString() ); - layers.insert( QStringLiteral("polygon_layer.shp"), QString() ); + layers.insert( QStringLiteral( "point_layer.shp" ), QString() ); + layers.insert( QStringLiteral( "line_layer.shp" ), QString() ); + layers.insert( QStringLiteral( "polygon_layer.shp" ), QString() ); auto testContext = createTestContext( dir, layers ); @@ -811,7 +829,8 @@ void TestQgsGeometryChecks::testPointCoveredByLineCheck() QStringList messages; QgsGeometryPointCoveredByLineCheck errs( testContext.first, QVariantMap() ); - errs.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + errs.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"] ).isEmpty() ); @@ -837,7 +856,8 @@ void TestQgsGeometryChecks::testPointInPolygonCheck() QStringList messages; QgsGeometryPointInPolygonCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QVERIFY( searchCheckErrors( checkErrors, layers["line_layer.shp"] ).isEmpty() ); @@ -866,7 +886,8 @@ void TestQgsGeometryChecks::testSegmentLengthCheck() configuration.insert( "minSegmentLength", 0.03 ); QgsGeometrySegmentLengthCheck check( testContext.first, configuration ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QCOMPARE( checkErrors.size(), 4 ); @@ -893,7 +914,8 @@ void TestQgsGeometryChecks::testSelfContactCheck() QStringList messages; QgsGeometrySelfContactCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QCOMPARE( checkErrors.size(), 3 ); @@ -919,7 +941,8 @@ void TestQgsGeometryChecks::testSelfIntersectionCheck() QStringList messages; QgsGeometrySelfIntersectionCheck check( testContext.first, QVariantMap() ); - check.collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + check.collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QList errs1; @@ -1026,7 +1049,8 @@ void TestQgsGeometryChecks::testSliverPolygonCheck() configuration.insert( "threshold", 20 ); configuration.insert( "maxArea", 0.04 ); - QgsGeometrySliverPolygonCheck( testContext.first, configuration ).collectErrors( testContext.second, checkErrors, messages ); + QgsFeedback feedback; + QgsGeometrySliverPolygonCheck( testContext.first, configuration ).collectErrors( testContext.second, checkErrors, messages, &feedback ); listErrors( checkErrors, messages ); QCOMPARE( checkErrors.size(), 2 );