Merge pull request #55371 from lbartoletti/fix_curve_wkt_maptool

QgsMapToolCapture: fix a regression
This commit is contained in:
Alessandro Pasotti 2023-12-13 11:23:48 +01:00 committed by GitHub
commit 269e1d74f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -1391,6 +1391,27 @@ void QgsMapToolCapture::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
}
else
{
//does compoundcurve contain circular strings?
//does provider support circular strings?
if ( QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer() ) )
{
const bool hasCurvedSegments = captureCurve()->hasCurvedSegments();
const bool providerSupportsCurvedSegments = vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::CircularGeometries;
if ( hasCurvedSegments && providerSupportsCurvedSegments )
{
curveToAdd = captureCurve()->clone();
}
else
{
curveToAdd = captureCurve()->curveToLine();
}
}
else
{
curveToAdd = captureCurve()->clone();
}
QgsCurvePolygon *poly = new QgsCurvePolygon();
poly->setExteriorRing( curveToAdd );
g = QgsGeometry( poly );

View File

@ -161,9 +161,7 @@ void TestQgsMapToolAddRing::testAddRing()
) );
mCaptureTool->cadCanvasReleaseEvent( event.get() );
// TODO: fix https://github.com/qgis/QGIS/issues/55361
// const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)))";
const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0),CompoundCurve ((1 1, 1 2, 2 2, 2 1, 1 1))))";
const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1)))";
QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), wkt );
}
@ -212,9 +210,7 @@ void TestQgsMapToolAddRing::testAddRingClockWise()
) );
mCaptureTool->cadCanvasReleaseEvent( event.get() );
// TODO: fix https://github.com/qgis/QGIS/issues/55361
// const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1), (3 3, 3 4, 4 4, 4 3, 3 3)))";
const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0),CompoundCurve ((1 1, 1 2, 2 2, 2 1, 1 1)),CompoundCurve ((3 3, 3 4, 4 4, 4 3, 3 3))))";
const QString wkt = "MultiPolygon (((0 0, 5 0, 5 5, 0 5, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1),(3 3, 3 4, 4 4, 4 3, 3 3)))";
QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), wkt );
}
QGSTEST_MAIN( TestQgsMapToolAddRing )