Skip to content
Permalink
Browse files

Avoid intersections in reshape tool

  • Loading branch information
arnaud-morvan authored and Hugo Mercier committed Apr 25, 2016
1 parent b758a8c commit 44cccfc0c6c16bcdf7ec418678c15bf81516b2e4
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/app/qgsmaptoolreshape.cpp
@@ -100,6 +100,28 @@ void QgsMapToolReshape::cadCanvasReleaseEvent( QgsMapMouseEvent * e )
reshapeReturn = geom->reshapeGeometry( points() );
if ( reshapeReturn == 0 )
{
//avoid intersections on polygon layers
if ( vlayer->geometryType() == QGis::Polygon )
{

//ignore all current layer features as they should be reshaped too
QMap<QgsVectorLayer*, QSet<QgsFeatureId>> ignoreFeatures;
ignoreFeatures.insert( vlayer, vlayer->allFeatureIds() );

int avoidIntersectionsReturn = geom->avoidIntersections( ignoreFeatures );
if ( avoidIntersectionsReturn == 1 )
{
//not a polygon type. Impossible to get there
}
if ( geom->isGeosEmpty() ) //avoid intersection might have removed the whole geometry
{
emit messageEmitted( tr( "The feature cannot be reshaped because resulting geometry is empty" ), QgsMessageBar::CRITICAL );
vlayer->destroyEditCommand();
stopCapturing();
return;
}
}

vlayer->changeGeometry( f.id(), geom );
reshapeDone = true;
}

0 comments on commit 44cccfc

Please sign in to comment.