Skip to content
Permalink
Browse files

Add a parameter to return if there is an error with a geometry

  • Loading branch information
lbartoletti authored and nyalldawson committed Feb 12, 2021
1 parent a208ec9 commit 97837100ff1c42574c7d455fc38bf213b3481e64
Showing with 11 additions and 4 deletions.
  1. +3 −2 src/core/geometry/qgsgeometry.cpp
  2. +8 −2 src/core/geometry/qgsgeometryeditutils.cpp
@@ -2602,12 +2602,13 @@ int QgsGeometry::avoidIntersections( const QList<QgsVectorLayer *> &avoidInterse
return 1;
}

std::unique_ptr< QgsAbstractGeometry > diffGeom = QgsGeometryEditUtils::avoidIntersections( *( d->geometry ), avoidIntersectionsLayers, ignoreFeatures );
bool haveGeometryError = false;
std::unique_ptr< QgsAbstractGeometry > diffGeom = QgsGeometryEditUtils::avoidIntersections( *( d->geometry ), avoidIntersectionsLayers, haveGeometryError, ignoreFeatures );
if ( diffGeom )
{
reset( std::move( diffGeom ) );
}
return 0;
return haveGeometryError ? 3 : 0;
}


@@ -224,7 +224,9 @@ bool QgsGeometryEditUtils::deletePart( QgsAbstractGeometry *geom, int partNum )

std::unique_ptr<QgsAbstractGeometry> QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometry &geom,
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures )
bool &haveGeometryError,
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures
)
{
std::unique_ptr<QgsGeometryEngine> geomEngine( QgsGeometry::createGeometryEngine( &geom ) );
if ( !geomEngine )
@@ -265,7 +267,11 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryEditUtils::avoidIntersections( c
if ( !f.hasGeometry() )
continue;

nearGeometries << f.geometry().makeValid();
QgsGeometry geomValid = f.geometry().makeValid();
if ( geomValid.isNull() )
haveGeometryError = true;
nearGeometries << geomValid;

}
}

0 comments on commit 9783710

Please sign in to comment.