18
18
#include " qgsgeometryoverlapcheck.h"
19
19
#include " qgsfeaturepool.h"
20
20
#include " qgsvectorlayer.h"
21
-
21
+ # include " qgsfeedback.h "
22
22
23
23
QgsGeometryOverlapCheck::QgsGeometryOverlapCheck ( const QgsGeometryCheckContext *context, const QVariantMap &configuration )
24
24
: QgsGeometryCheck( context, configuration )
@@ -35,6 +35,9 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
35
35
QList<QString> layerIds = featureIds.keys ();
36
36
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureA : layerFeaturesA )
37
37
{
38
+ if ( feedback->isCanceled () )
39
+ break ;
40
+
38
41
// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
39
42
layerIds.removeOne ( layerFeatureA.layer ()->id () );
40
43
@@ -49,6 +52,9 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
49
52
const QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB ( featurePools, QList<QString>() << layerFeatureA.layer ()->id () << layerIds, bboxA, compatibleGeometryTypes (), mContext );
50
53
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
51
54
{
55
+ if ( feedback->isCanceled () )
56
+ break ;
57
+
52
58
// > : only report overlaps within same layer once
53
59
if ( layerFeatureA.layer ()->id () == layerFeatureB.layer ()->id () && layerFeatureB.feature ().id () >= layerFeatureA.feature ().id () )
54
60
{
@@ -57,13 +63,13 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
57
63
QString errMsg;
58
64
if ( geomEngineA->overlaps ( layerFeatureB.geometry ().constGet (), &errMsg ) )
59
65
{
60
- QgsAbstractGeometry * interGeom = geomEngineA->intersection ( layerFeatureB.geometry ().constGet () );
66
+ std::unique_ptr< QgsAbstractGeometry> interGeom ( geomEngineA->intersection ( layerFeatureB.geometry ().constGet () ) );
61
67
if ( interGeom && !interGeom->isEmpty () )
62
68
{
63
- QgsGeometryCheckerUtils::filter1DTypes ( interGeom );
69
+ QgsGeometryCheckerUtils::filter1DTypes ( interGeom. get () );
64
70
for ( int iPart = 0 , nParts = interGeom->partCount (); iPart < nParts; ++iPart )
65
71
{
66
- QgsAbstractGeometry *interPart = QgsGeometryCheckerUtils::getGeomPart ( interGeom, iPart );
72
+ QgsAbstractGeometry *interPart = QgsGeometryCheckerUtils::getGeomPart ( interGeom. get () , iPart );
67
73
double area = interPart->area ();
68
74
if ( area > mContext ->reducedTolerance && ( area < mOverlapThresholdMapUnits || mOverlapThresholdMapUnits == 0.0 ) )
69
75
{
@@ -75,7 +81,6 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
75
81
{
76
82
messages.append ( tr ( " Overlap check between features %1 and %2 %3" ).arg ( layerFeatureA.id (), layerFeatureB.id (), errMsg ) );
77
83
}
78
- delete interGeom;
79
84
}
80
85
}
81
86
}
0 commit comments