Skip to content

Commit

Permalink
Avoid intersections in reshape tool
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan authored and Hugo Mercier committed Apr 25, 2016
1 parent b758a8c commit 44cccfc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/qgsmaptoolreshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 44cccfc

Please sign in to comment.