Skip to content
Permalink
Browse files

backport #42713

  • Loading branch information
vcloarec authored and nyalldawson committed Apr 17, 2021
1 parent 8376148 commit 58b78f34d49f631b644eef7ee8d38c48dc83809c
@@ -144,8 +144,8 @@ void QgsMapToolAddCircularString::activate()
{
//mParentTool->captureCurve() is in layer coordinates, but we need map coordinates
QgsPoint endPointLayerCoord = curve->endPoint();
QgsPointXY mapPoint = toMapCoordinates( mCanvas->currentLayer(), QgsPointXY( endPointLayerCoord.x(), endPointLayerCoord.y() ) );
mPoints.append( QgsPoint( mapPoint ) );
QgsPoint mapPoint = toMapCoordinates( mCanvas->currentLayer(), endPointLayerCoord );
mPoints.append( mapPoint );
if ( !mTempRubberBand )
{
mTempRubberBand = createGeometryRubberBand( mLayerType, true );
@@ -603,7 +603,7 @@ int QgsMapToolCapture::addVertex( const QgsPointXY &point, const QgsPointLocator
mCaptureLastPoint = mapPoint;
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry, mDigitizingType, firstCapturedMapPoint() );
}
else if ( mCaptureCurve.numPoints() == 0 )
else if ( mTempRubberBand->pointsCount() == 0 )
{
mCaptureLastPoint = mapPoint;
mCaptureCurve.addVertex( layerPoint );
@@ -42,6 +42,7 @@ class TestQgsMapToolCircularString : public QObject
void testAddCircularStringRadius();
void testAddCircularStringCurvePointWithDeletedVertex();
void testAddCircularStringRadiusWithDeletedVertex();
void testAddCircularStringAfterClassicDigitizing();

private:
QgisApp *mQgisApp = nullptr;
@@ -187,5 +188,43 @@ void TestQgsMapToolCircularString::testAddCircularStringRadiusWithDeletedVertex(
mLayer->rollBack();
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
}

void TestQgsMapToolCircularString::testAddCircularStringAfterClassicDigitizing()
{
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 333 );
mLayer->startEditing();

TestQgsMapToolAdvancedDigitizingUtils utilsClassic( mParentTool );

mCanvas->setMapTool( mParentTool );
utilsClassic.mouseClick( 2, 1, Qt::LeftButton );
utilsClassic.mouseClick( 2, 0, Qt::LeftButton );
utilsClassic.mouseClick( 0, 0, Qt::LeftButton );

QgsMapToolCircularStringCurvePoint mapTool( mParentTool, mCanvas );
mCanvas->setMapTool( &mapTool );

TestQgsMapToolAdvancedDigitizingUtils utilsCircular( &mapTool );
utilsCircular.mouseClick( 1, 1, Qt::LeftButton );
utilsCircular.mouseClick( 0, 2, Qt::LeftButton );

mCanvas->setMapTool( mParentTool );
utilsClassic.mouseClick( 2, 2, Qt::LeftButton );
utilsClassic.mouseClick( 4, 2, Qt::LeftButton );

utilsCircular.mouseClick( 4, 2, Qt::RightButton );
QgsFeatureId newFid = utilsCircular.newFeatureId();

QCOMPARE( mLayer->featureCount(), ( long )1 );
QgsFeature f = mLayer->getFeature( newFid );

qDebug() << f.geometry().asWkt();

QString wkt = "CompoundCurveZ ((2 1 333, 2 0 333),(2 0 333, 0 0 333),CircularStringZ (0 0 333, 1 1 333, 0 2 333),(0 2 333, 2 2 333),(2 2 333, 4 2 333))";
QCOMPARE( f.geometry().asWkt(), wkt );

mLayer->rollBack();
QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/default_z_value" ), 0 );
}
QGSTEST_MAIN( TestQgsMapToolCircularString )
#include "testqgsmaptoolcircularstring.moc"

0 comments on commit 58b78f3

Please sign in to comment.