Skip to content
Permalink
Browse files

Add a message if there is an unfixable error with a geometry

  • Loading branch information
lbartoletti authored and nyalldawson committed Feb 12, 2021
1 parent 9783710 commit 282ccb9b01f05085bdc09942bb22fb274dfd9796
Showing with 4 additions and 2 deletions.
  1. +2 −0 src/core/geometry/qgsgeometryeditutils.h
  2. +2 −2 src/gui/qgsmaptooldigitizefeature.cpp
@@ -71,10 +71,12 @@ class QgsGeometryEditUtils
* Alters a geometry so that it avoids intersections with features from all open vector layers.
* \param geom geometry to alter
* \param avoidIntersectionsLayers list of layers to check for intersections
* \param haveGeometryError the method will use GEOS to fix the geometries, if at least one geometry cannot be fixed, it returns false (The geometry, may not be modified.)
* \param ignoreFeatures map of layer to feature id of features to ignore
*/
static std::unique_ptr< QgsAbstractGeometry > avoidIntersections( const QgsAbstractGeometry &geom,
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
bool &haveGeometryError,
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
};

@@ -341,9 +341,9 @@ void QgsMapToolDigitizeFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
QgsGeometry featGeom = f->geometry();
int avoidIntersectionsReturn = featGeom.avoidIntersections( avoidIntersectionsLayers );
f->setGeometry( featGeom );
if ( avoidIntersectionsReturn == 1 )
if ( avoidIntersectionsReturn == 3 )
{
//not a polygon type. Impossible to get there
emit messageEmitted( tr( "The feature has been added, but at least one geometry intersected is invalid and cannot be fixed automaticaly. The geometry added may overlap another geometry. You should fix geometries." ), Qgis::Warning );
}
if ( f->geometry().isEmpty() ) //avoid intersection might have removed the whole geometry
{

0 comments on commit 282ccb9

Please sign in to comment.