Skip to content

Commit

Permalink
Fix nested CompoundCurves
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 4, 2023
1 parent 6dde6ee commit 28b6d3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/core/geometry/qgsinternalgeometryengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,12 +1361,12 @@ std::unique_ptr< QgsCurve > lineToCurve( const QgsCurve *curve, double distanceT
std::unique_ptr< QgsCurve > processed = lineToCurve( in->curveAt( i ), distanceTolerance, pointSpacingAngleTolerance );
if ( processed )
{
// check the simplified type ref of the geometry to see if it consists of just a single linestring component.
// If so, we extract this line string along, so that we don't create geometry components which consits of a
// compound curve with only linestring parts.
if ( QgsWkbTypes::flatType( processed->simplifiedTypeRef()->wkbType() ) == Qgis::WkbType::LineString )
if ( const QgsCompoundCurve *processedCompoundCurve = qgsgeometry_cast< const QgsCompoundCurve *>( processed.get() ) )
{
out->addCurve( qgsgeometry_cast< const QgsLineString * >( processed->simplifiedTypeRef() )->clone() );
for ( int i = 0; i < processedCompoundCurve->nCurves(); ++i )
{
out->addCurve( processedCompoundCurve->curveAt( i )->clone() );
}
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion tests/src/python/test_qgsgeometry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""QGIS Unit tests for QgsGeometry.
"""QGIS Unit tests for QgsGeometry.

Check failure on line 1 in tests/src/python/test_qgsgeometry.py

View workflow job for this annotation

GitHub Actions / Python Lint

tests/src/python/test_qgsgeometry.py#L1

[W291] trailing whitespace
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -6121,6 +6121,9 @@ def testConvertToCurves(self):
0.00000001],
["CurvePolygon (CompoundCurve (CircularString (2613627 1178798, 2613639 1178805, 2613648 1178794),(2613648 1178794, 2613627 1178798)))",
"CurvePolygon (CompoundCurve (CircularString (2613627 1178798, 2613639 1178805, 2613648 1178794),(2613648 1178794, 2613627 1178798)))",
0.00000001, 0.000000001],
["CurvePolygon (CompoundCurve ((2653264.45800000010058284 1213405.36899999994784594, 2653279.07700000004842877 1213383.28700000001117587, 2653278.33142686076462269 1213384.25132044195197523, 2653277.59772348683327436 1213385.22470247372984886, 2653276.87600000016391277 1213386.20699999993667006))",
"CurvePolygon (CompoundCurve ((2653264.45800000010058284 1213405.36899999994784594, 2653279.07700000004842877 1213383.28700000001117587),CircularString (2653279.07700000004842877 1213383.28700000001117587, 2653278.33142686076462269 1213384.25132044195197523, 2653276.87600000016391277 1213386.20699999993667006)))",
0.00000001, 0.000000001]
]
for t in tests:
Expand Down

0 comments on commit 28b6d3b

Please sign in to comment.