Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #41817 from m-kuhn/compound_curve_remove_multiple_…
Browse files Browse the repository at this point in the history
…dups

Fix QgsCompoundCurve::removeDuplicateNodes with multiple duplicate nodes
  • Loading branch information
m-kuhn authored and nyalldawson committed Feb 25, 2021
1 parent e66a8cc commit d7ff585
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/geometry/qgscompoundcurve.cpp
Expand Up @@ -427,7 +427,7 @@ bool QgsCompoundCurve::removeDuplicateNodes( double epsilon, bool useZValues )
QgsPoint lastEnd;
for ( QgsCurve *curve : curves )
{
result = result || curve->removeDuplicateNodes( epsilon, useZValues );
result = curve->removeDuplicateNodes( epsilon, useZValues ) || result;
if ( curve->numPoints() == 0 || qgsDoubleNear( curve->length(), 0.0, epsilon ) )
{
// empty curve, remove it
Expand Down
5 changes: 5 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -11904,6 +11904,11 @@ void TestQgsGeometry::compoundCurve()
QVERIFY( nodeCurve.removeDuplicateNodes( 0.02 ) );
QCOMPARE( nodeCurve.asWkt( 2 ), QStringLiteral( "CompoundCurve (CircularString (11 2, 11 12, 111 12, 111.01 11.99))" ) );

// with multiple duplicate nodes
nodeCurve.fromWkt( QStringLiteral( "CompoundCurve ((11 1, 11 2, 11 2),CircularString(11 2, 10 3, 10 2),(10 2, 10 2, 11 1))" ) );
QVERIFY( nodeCurve.removeDuplicateNodes( 0.02 ) );
QCOMPARE( nodeCurve.asWkt( 0 ), QStringLiteral( "CompoundCurve ((11 1, 11 2),CircularString (11 2, 10 3, 10 2),(10 2, 11 1))" ) );

// ensure continuity
nodeCurve.clear();
linePart.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) << QgsPoint( 111.01, 11.99 ) << QgsPoint( 111, 12 ) );
Expand Down

0 comments on commit d7ff585

Please sign in to comment.