Skip to content
Permalink
Browse files

Abort geometry checks if feedback is cancelled

  • Loading branch information
m-kuhn committed Oct 1, 2018
1 parent e300387 commit 42c3f4549c4bd119ccf048efb4d5f4fec2ef8110
@@ -44,6 +44,13 @@ void QgsGeometryGapCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeature : layerFeatures )
{
geomList.append( layerFeature.geometry().constGet()->clone() );

if ( feedback->isCanceled() )
{
qDeleteAll( geomList );
geomList.clear();
break;
}
}

if ( geomList.isEmpty() )
@@ -43,11 +43,16 @@ void QgsGeometryMissingVertexCheck::collectErrors( const QMap<QString, QgsFeatur

for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeature : layerFeatures )
{
if ( feedback->isCanceled() )
{
break;
}

const QgsAbstractGeometry *geom = layerFeature.geometry().constGet();

if ( QgsCurvePolygon *polygon = qgsgeometry_cast<QgsCurvePolygon *>( geom ) )
{
processPolygon( polygon, featurePool, errors, layerFeature );
processPolygon( polygon, featurePool, errors, layerFeature, feedback );
}
else if ( QgsGeometryCollection *collection = qgsgeometry_cast<QgsGeometryCollection *>( geom ) )
{
@@ -56,7 +61,7 @@ void QgsGeometryMissingVertexCheck::collectErrors( const QMap<QString, QgsFeatur
{
if ( QgsCurvePolygon *polygon = qgsgeometry_cast<QgsCurvePolygon *>( collection->geometryN( i ) ) )
{
processPolygon( polygon, featurePool, errors, layerFeature );
processPolygon( polygon, featurePool, errors, layerFeature, feedback );
}
}
}
@@ -105,7 +110,7 @@ QString QgsGeometryMissingVertexCheck::description() const
return factoryDescription();
}

void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polygon, QgsFeaturePool *featurePool, QList<QgsGeometryCheckError *> &errors, const QgsGeometryCheckerUtils::LayerFeature &layerFeature ) const
void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polygon, QgsFeaturePool *featurePool, QList<QgsGeometryCheckError *> &errors, const QgsGeometryCheckerUtils::LayerFeature &layerFeature, QgsFeedback *feedback ) const
{
const QgsFeature &currentFeature = layerFeature.feature();
std::unique_ptr<QgsMultiPolygon> boundaries = qgis::make_unique<QgsMultiPolygon>();
@@ -133,6 +138,9 @@ void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polyg

if ( featurePool->getFeature( fid, compareFeature ) )
{
if ( feedback->isCanceled() )
break;

QgsVertexIterator vertexIterator = compareFeature.geometry().vertices();
while ( vertexIterator.hasNext() )
{
@@ -62,7 +62,7 @@ class ANALYSIS_EXPORT QgsGeometryMissingVertexCheck : public QgsGeometryCheck
///@endcond

private:
void processPolygon( const QgsCurvePolygon *polygon, QgsFeaturePool *featurePool, QList<QgsGeometryCheckError *> &errors, const QgsGeometryCheckerUtils::LayerFeature &layerFeature ) const;
void processPolygon( const QgsCurvePolygon *polygon, QgsFeaturePool *featurePool, QList<QgsGeometryCheckError *> &errors, const QgsGeometryCheckerUtils::LayerFeature &layerFeature, QgsFeedback *feedback ) const;
};


@@ -18,7 +18,7 @@
#include "qgsgeometryoverlapcheck.h"
#include "qgsfeaturepool.h"
#include "qgsvectorlayer.h"

#include "qgsfeedback.h"

QgsGeometryOverlapCheck::QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration )
: QgsGeometryCheck( context, configuration )
@@ -35,6 +35,9 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
QList<QString> layerIds = featureIds.keys();
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureA : layerFeaturesA )
{
if ( feedback->isCanceled() )
break;

// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
layerIds.removeOne( layerFeatureA.layer()->id() );

@@ -49,6 +52,9 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
const QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( featurePools, QList<QString>() << layerFeatureA.layer()->id() << layerIds, bboxA, compatibleGeometryTypes(), mContext );
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
{
if ( feedback->isCanceled() )
break;

// > : only report overlaps within same layer once
if ( layerFeatureA.layer()->id() == layerFeatureB.layer()->id() && layerFeatureB.feature().id() >= layerFeatureA.feature().id() )
{
@@ -57,13 +63,13 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
QString errMsg;
if ( geomEngineA->overlaps( layerFeatureB.geometry().constGet(), &errMsg ) )
{
QgsAbstractGeometry *interGeom = geomEngineA->intersection( layerFeatureB.geometry().constGet() );
std::unique_ptr<QgsAbstractGeometry> interGeom( geomEngineA->intersection( layerFeatureB.geometry().constGet() ) );
if ( interGeom && !interGeom->isEmpty() )
{
QgsGeometryCheckerUtils::filter1DTypes( interGeom );
QgsGeometryCheckerUtils::filter1DTypes( interGeom.get() );
for ( int iPart = 0, nParts = interGeom->partCount(); iPart < nParts; ++iPart )
{
QgsAbstractGeometry *interPart = QgsGeometryCheckerUtils::getGeomPart( interGeom, iPart );
QgsAbstractGeometry *interPart = QgsGeometryCheckerUtils::getGeomPart( interGeom.get(), iPart );
double area = interPart->area();
if ( area > mContext->reducedTolerance && ( area < mOverlapThresholdMapUnits || mOverlapThresholdMapUnits == 0.0 ) )
{
@@ -75,7 +81,6 @@ void QgsGeometryOverlapCheck::collectErrors( const QMap<QString, QgsFeaturePool
{
messages.append( tr( "Overlap check between features %1 and %2 %3" ).arg( layerFeatureA.id(), layerFeatureB.id(), errMsg ) );
}
delete interGeom;
}
}
}

0 comments on commit 42c3f45

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