Skip to content

Commit 44cccfc

Browse files
arnaud-morvanHugo Mercier
authored andcommitted
Avoid intersections in reshape tool
1 parent b758a8c commit 44cccfc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/app/qgsmaptoolreshape.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)