File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,22 @@ void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e )
125
125
{
126
126
// close polygon
127
127
closePolygon ();
128
+ // avoid intersections
129
+ QgsGeometry* geom = QgsGeometry::fromPolygon ( QgsPolygon () << points ().toVector () );
130
+ if ( geom )
131
+ {
132
+ geom->avoidIntersections ();
133
+ QgsPolygon poly = geom->asPolygon ();
134
+ if ( poly.size () < 1 )
135
+ {
136
+ stopCapturing ();
137
+ delete geom;
138
+ vlayer->destroyEditCommand ();
139
+ return ;
140
+ }
141
+ setPoints ( geom->asPolygon ()[0 ].toList () );
142
+ delete geom;
143
+ }
128
144
}
129
145
130
146
vlayer->beginEditCommand ( tr ( " Part added" ) );
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ class QgsMapToolCapture : public QgsMapToolEdit
91
91
QList<QgsPoint>::iterator begin () { return mCaptureList .begin (); }
92
92
QList<QgsPoint>::iterator end () { return mCaptureList .end (); }
93
93
const QList<QgsPoint> &points () { return mCaptureList ; }
94
+ void setPoints ( const QList<QgsPoint>& pointList ) { mCaptureList = pointList; }
94
95
void closePolygon ();
95
96
96
97
private:
You can’t perform that action at this time.
0 commit comments