Skip to content
Permalink
Browse files

[selfsnap] followup : snap to closing line of poly and fix geos error…

… message
  • Loading branch information
olivierdalang committed May 22, 2020
1 parent 66bfde6 commit 02c7a9a7e1822d1a9189107ce29b85ae6263c74a
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/gui/qgsmaptoolcapture.cpp
@@ -526,7 +526,6 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
// ordinary digitizing
mRubberBand->addPoint( point );
mCaptureCurve.addVertex( layerPoint );
updateExtraSnapLayer();
mSnappingMatches.append( match );
}

@@ -542,6 +541,7 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
mTempRubberBand->addPoint( point );
}

updateExtraSnapLayer();
validateGeometry();

return 0;
@@ -892,11 +892,16 @@ QgsPoint QgsMapToolCapture::mapPoint( const QgsMapMouseEvent &e ) const

void QgsMapToolCapture::updateExtraSnapLayer()
{
if ( canvas()->snappingUtils()->config().selfSnapping() && mCanvas->currentLayer() )
if ( canvas()->snappingUtils()->config().selfSnapping() && mCanvas->currentLayer() && mCaptureCurve.numPoints() >= 2 )
{
// the current layer may have changed
mExtraSnapLayer->setCrs( mCanvas->currentLayer()->crs() );
QgsGeometry geom = QgsGeometry( mCaptureCurve.clone() );
// we close the curve to allow snapping on last segment
if ( mCaptureMode == CapturePolygon && mCaptureCurve.numPoints() >= 3 )
{
qgsgeometry_cast<QgsCompoundCurve *>( geom.get() )->close();
}
mExtraSnapLayer->changeGeometry( mExtraSnapFeatureId, geom );
}
else

0 comments on commit 02c7a9a

Please sign in to comment.
You can’t perform that action at this time.