File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,28 @@ void QgsMapToolReshape::cadCanvasReleaseEvent( QgsMapMouseEvent * e )
100100 reshapeReturn = geom->reshapeGeometry ( points () );
101101 if ( reshapeReturn == 0 )
102102 {
103+ // avoid intersections on polygon layers
104+ if ( vlayer->geometryType () == QGis::Polygon )
105+ {
106+
107+ // ignore all current layer features as they should be reshaped too
108+ QMap<QgsVectorLayer*, QSet<QgsFeatureId>> ignoreFeatures;
109+ ignoreFeatures.insert ( vlayer, vlayer->allFeatureIds () );
110+
111+ int avoidIntersectionsReturn = geom->avoidIntersections ( ignoreFeatures );
112+ if ( avoidIntersectionsReturn == 1 )
113+ {
114+ // not a polygon type. Impossible to get there
115+ }
116+ if ( geom->isGeosEmpty () ) // avoid intersection might have removed the whole geometry
117+ {
118+ emit messageEmitted ( tr ( " The feature cannot be reshaped because resulting geometry is empty" ), QgsMessageBar::CRITICAL );
119+ vlayer->destroyEditCommand ();
120+ stopCapturing ();
121+ return ;
122+ }
123+ }
124+
103125 vlayer->changeGeometry ( f.id (), geom );
104126 reshapeDone = true ;
105127 }
You can’t perform that action at this time.
0 commit comments