Skip to content
Permalink
Browse files
[Backport]: Avoid intersection for QgsMapToolAddPart. Fixes ticket #4624
  • Loading branch information
mhugent committed Feb 18, 2012
1 parent a9a9b93 commit a1ac714fde085895728b653ffc8e42f7a9b57f0e
Showing with 17 additions and 0 deletions.
  1. +16 −0 src/app/qgsmaptooladdpart.cpp
  2. +1 −0 src/app/qgsmaptoolcapture.h
@@ -125,6 +125,22 @@ void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e )
{
//close polygon
closePolygon();
//avoid intersections
QgsGeometry* geom = QgsGeometry::fromPolygon( QgsPolygon() << points().toVector() );
if ( geom )
{
geom->avoidIntersections();
QgsPolygon poly = geom->asPolygon();
if ( poly.size() < 1 )
{
stopCapturing();
delete geom;
vlayer->destroyEditCommand();
return;
}
setPoints( geom->asPolygon()[0].toList() );
delete geom;
}
}

vlayer->beginEditCommand( tr( "Part added" ) );
@@ -91,6 +91,7 @@ class QgsMapToolCapture : public QgsMapToolEdit
QList<QgsPoint>::iterator begin() { return mCaptureList.begin(); }
QList<QgsPoint>::iterator end() { return mCaptureList.end(); }
const QList<QgsPoint> &points() { return mCaptureList; }
void setPoints( const QList<QgsPoint>& pointList ) { mCaptureList = pointList; }
void closePolygon();

private:

0 comments on commit a1ac714

Please sign in to comment.