From dc074b393e800368bd0ed35b137d9dd930b73f75 Mon Sep 17 00:00:00 2001 From: Marco Hugentobler Date: Mon, 18 Feb 2013 17:08:08 +0100 Subject: [PATCH] Always use topological editing if using avoid intersection (where possible also to background layers). Without topological editing, it is possible to have very small gaps between the polygons --- src/app/qgsmaptooladdfeature.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index e0f4fe0753e..9828aea7bad 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -273,7 +273,26 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) { //add points to other features to keep topology up-to-date int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); - if ( topologicalEditing ) + + //use always topological editing for avoidIntersection. + //Otherwise, no way to guarantee the geometries don't have a small gap in between. + QStringList intersectionLayers = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList" ); + bool avoidIntersection = !intersectionLayers.isEmpty(); + if ( avoidIntersection ) //try to add topological points also to background layers + { + QStringList::const_iterator lIt = intersectionLayers.constBegin(); + for ( ; lIt != intersectionLayers.constEnd(); ++lIt ) + { + QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer( *lIt ); + QgsVectorLayer* vl = qobject_cast( ml ); + //can only add topological points if background layer is editable... + if ( vl && vl->geometryType() == QGis::Polygon && vl->isEditable() ) + { + vl->addTopologicalPoints( f->geometry() ); + } + } + } + else if ( topologicalEditing ) { vlayer->addTopologicalPoints( f->geometry() ); }