Skip to content

Commit 02c7a9a

Browse files
committedMay 22, 2020
[selfsnap] followup : snap to closing line of poly and fix geos error message
1 parent 66bfde6 commit 02c7a9a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎src/gui/qgsmaptoolcapture.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
526526
// ordinary digitizing
527527
mRubberBand->addPoint( point );
528528
mCaptureCurve.addVertex( layerPoint );
529-
updateExtraSnapLayer();
530529
mSnappingMatches.append( match );
531530
}
532531

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

544+
updateExtraSnapLayer();
545545
validateGeometry();
546546

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

893893
void QgsMapToolCapture::updateExtraSnapLayer()
894894
{
895-
if ( canvas()->snappingUtils()->config().selfSnapping() && mCanvas->currentLayer() )
895+
if ( canvas()->snappingUtils()->config().selfSnapping() && mCanvas->currentLayer() && mCaptureCurve.numPoints() >= 2 )
896896
{
897897
// the current layer may have changed
898898
mExtraSnapLayer->setCrs( mCanvas->currentLayer()->crs() );
899899
QgsGeometry geom = QgsGeometry( mCaptureCurve.clone() );
900+
// we close the curve to allow snapping on last segment
901+
if ( mCaptureMode == CapturePolygon && mCaptureCurve.numPoints() >= 3 )
902+
{
903+
qgsgeometry_cast<QgsCompoundCurve *>( geom.get() )->close();
904+
}
900905
mExtraSnapLayer->changeGeometry( mExtraSnapFeatureId, geom );
901906
}
902907
else

0 commit comments

Comments
 (0)
Please sign in to comment.