Skip to content

Commit

Permalink
Do not report duplicate errors in missing vertex check
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 26, 2018
1 parent f78bdf0 commit b05ea1a
Showing 1 changed file with 18 additions and 6 deletions.
Expand Up @@ -75,7 +75,8 @@ QStringList QgsGeometryMissingVertexCheck::resolutionMethods() const

void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polygon, QgsFeaturePool *featurePool, QList<QgsGeometryCheckError *> &errors, const QgsGeometryCheckerUtils::LayerFeature &layerFeature ) const
{
std::unique_ptr<QgsGeometryCollection> boundaries = qgis::make_unique<QgsGeometryCollection>();
const QgsFeature &currentFeature = layerFeature.feature();
std::unique_ptr<QgsMultiPolygon> boundaries = qgis::make_unique<QgsMultiPolygon>();

std::unique_ptr< QgsGeometryEngine > geomEngine = QgsGeometryCheckerUtils::createGeomEngine( polygon->exteriorRing(), mContext->tolerance );
boundaries->addGeometry( geomEngine->buffer( mContext->tolerance, 5 ) );
Expand All @@ -92,15 +93,15 @@ void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polyg

const QgsFeatureIds fids = featurePool->getIntersects( boundaries->boundingBox() );

QgsFeature feature;
QgsFeature compareFeature;
for ( QgsFeatureId fid : fids )
{
if ( fid == layerFeature.feature().id() )
if ( fid == currentFeature.id() )
continue;

if ( featurePool->getFeature( fid, feature ) )
if ( featurePool->getFeature( fid, compareFeature ) )
{
QgsVertexIterator vertexIterator = feature.geometry().vertices();
QgsVertexIterator vertexIterator = compareFeature.geometry().vertices();
while ( vertexIterator.hasNext() )
{
const QgsPoint &pt = vertexIterator.next();
Expand All @@ -111,7 +112,18 @@ void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polyg

if ( closestVertex.distance( pt ) > mContext->tolerance )
{
errors.append( new QgsGeometryCheckError( this, layerFeature, QgsPointXY( pt ) ) );
bool alreadyReported = false;
for ( QgsGeometryCheckError *error : qgis::as_const( errors ) )
{
// Only list missing vertices once
if ( error->featureId() == currentFeature.id() && error->location() == QgsPointXY( pt ) )
{
alreadyReported = true;
break;
}
}
if ( !alreadyReported )
errors.append( new QgsGeometryCheckError( this, layerFeature, QgsPointXY( pt ) ) );
}
}
}
Expand Down

0 comments on commit b05ea1a

Please sign in to comment.