Skip to content

Commit

Permalink
[Geometry checker] Use centroid of actual hole to report error in Qgs…
Browse files Browse the repository at this point in the history
…GeometryHoleCheck
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent edf563b commit 737d513
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometryholecheck.cpp
Expand Up @@ -14,6 +14,8 @@
***************************************************************************/

#include "qgsgeometryholecheck.h"
#include "qgscurve.h"
#include "qgscurvepolygon.h"
#include "qgsfeaturepool.h"

void QgsGeometryHoleCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
Expand All @@ -25,10 +27,16 @@ void QgsGeometryHoleCheck::collectErrors( QList<QgsGeometryCheckError *> &errors
const QgsAbstractGeometry *geom = layerFeature.geometry();
for ( int iPart = 0, nParts = geom->partCount(); iPart < nParts; ++iPart )
{
const QgsCurvePolygon *poly = dynamic_cast<const QgsCurvePolygon *>( QgsGeometryCheckerUtils::getGeomPart( geom, iPart ) );
if ( !poly )
{
continue;
}
// Rings after the first one are interiors
for ( int iRing = 1, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing )
for ( int iRing = 1, nRings = poly->ringCount( iPart ); iRing < nRings; ++iRing )
{
QgsPoint pos = QgsGeometryCheckerUtils::getGeomPart( geom, iPart )->centroid();

QgsPoint pos = poly->interiorRing( iRing - 1 )->centroid();
errors.append( new QgsGeometryCheckError( this, layerFeature, pos, QgsVertexId( iPart, iRing ) ) );
}
}
Expand Down

0 comments on commit 737d513

Please sign in to comment.