This commit is contained in:
Nyall Dawson 2024-06-04 11:00:32 +10:00
parent 026e8c1efe
commit 51eece171d

View File

@ -2597,13 +2597,17 @@ void TestQgsGeometry::snappedToGrid()
QCOMPARE( snapped->asWkt( 5 ), QStringLiteral( "LineStringZM (68 415 10 60, 27 505 20 50, 27 406 40 30)" ) );
// with removal of redundant vertices
curve = QgsGeometry::fromWkt( "LineString( 68.1 415.2, 27.1 505.2, 27.1 406.2 )" );
curve.densifyByCount( 10 );
curve = QgsGeometry::fromWkt( "LineString( 68.1 415.2, 68.1 505.2, 27.1 505.2 )" );
curve = curve.densifyByCount( 10 );
// no removal of redundant vertices
snapped.reset( curve.constGet()->snappedToGrid( 1, 1, 0, 0, false ) );
QCOMPARE( snapped->nCoordinates(), 23 );
// removal of redundant vertices
snapped.reset( curve.constGet()->snappedToGrid( 1, 1, 0, 0, true ) );
QCOMPARE( snapped->asWkt( 5 ), QStringLiteral( "LineString (68 415, 27 505, 27 406)" ) );
curve.densifyByCount( 1000 );
QCOMPARE( snapped->asWkt( 5 ), QStringLiteral( "LineString (68 415, 68 505, 27 505)" ) );
curve = curve.densifyByCount( 1000 );
snapped.reset( curve.constGet()->snappedToGrid( 1, 1, 0, 0, true ) );
QCOMPARE( snapped->asWkt( 5 ), QStringLiteral( "LineString (68 415, 27 505, 27 406)" ) );
QCOMPARE( snapped->asWkt( 5 ), QStringLiteral( "LineString (68 415, 68 505, 27 505)" ) );
}
//compound curve