Skip to content
Permalink
Browse files

fix duplicate point at the beginning of a digitized curve

fix #39974
  • Loading branch information
vcloarec committed Nov 17, 2020
1 parent 57040e2 commit 694849d4feeee898ca3181513d3f07eb5b0e0339
Showing with 13 additions and 3 deletions.
  1. +3 −0 src/gui/qgsmaptoolcapture.cpp
  2. +10 −3 tests/src/app/testqgsmaptooladdfeatureline.cpp
@@ -654,6 +654,9 @@ int QgsMapToolCapture::addCurve( QgsCurve *c )
c->transform( ct, QgsCoordinateTransform::ReverseTransform );
}
int countBefore = mCaptureCurve.vertexCount();
//if there is only one point, this the first digitized point that are in the this first curve added --> remove the point
if ( mCaptureCurve.numPoints() == 1 )
mCaptureCurve.removeCurve( 0 );
mCaptureCurve.addCurve( c );
int countAfter = mCaptureCurve.vertexCount();
int addedPoint = countAfter - countBefore;
@@ -289,7 +289,7 @@ void TestQgsMapToolAddFeatureLine::testNoTracing()
utils.mouseClick( 3, 2, Qt::LeftButton );
utils.mouseClick( 3, 2, Qt::RightButton );

// Cirular string need 3 points, so no feature created
// Circular string need 3 points, so no feature created
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
QCOMPARE( utils.existingFeatureIds().count(), 1 );

@@ -298,13 +298,20 @@ void TestQgsMapToolAddFeatureLine::testNoTracing()
utils.mouseClick( 3, 2, Qt::LeftButton );
utils.mouseMove( 5, 5 );
utils.mouseClick( 4, 2, Qt::LeftButton );

mCaptureTool->setCircularDigitizingEnabled( false );

utils.mouseMove( 5, 5 );
utils.mouseClick( 4, 3, Qt::LeftButton );

utils.mouseMove( 5, 5 );
utils.mouseClick( 4, 2, Qt::RightButton );
utils.mouseClick( 4, 4, Qt::RightButton );

newFid = utils.newFeatureId( oldFids );

QCOMPARE( mLayerLine->undoStack()->index(), 2 );
QCOMPARE( mLayerLine->getFeature( newFid ).geometry(), QgsGeometry::fromWkt( "CIRCULARSTRING(1 1, 3 2, 4 2)" ) );
// as here, QCOMPARE with QgsGeometry uses isGeosEqual() and geos does not support curve (need to convert curve to line string), test with wkt string
QCOMPARE( mLayerLine->getFeature( newFid ).geometry().asWkt(), QStringLiteral( "CompoundCurve (CircularString (1 1, 3 2, 4 2),(4 2, 4 3))" ) ) ;

mLayerLine->undoStack()->undo();
QCOMPARE( mLayerLine->undoStack()->index(), 1 );

0 comments on commit 694849d

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