mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-10 00:13:55 -04:00
Correct test comparisons
Previously QCOMPARE( QgsGeometry, QgsGeometry ) was actually only testing for QCOMPARE( bool(QgsGeometry), bool(QgsGeometry) )...!
This commit is contained in:
parent
7be2925649
commit
18d4059546
@ -16933,7 +16933,7 @@ void TestQgsGeometry::minimalEnclosingCircle()
|
||||
QCOMPARE( radius, 0.0 );
|
||||
QVERIFY( result.isNull() );
|
||||
|
||||
// caase 1
|
||||
// case 1
|
||||
geomTest = QgsGeometry::fromPointXY( QgsPointXY( 5, 5 ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
QCOMPARE( center, QgsPointXY( 5, 5 ) );
|
||||
@ -16943,47 +16943,44 @@ void TestQgsGeometry::minimalEnclosingCircle()
|
||||
|
||||
// case 2
|
||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 3 8, 7 4 )" ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
|
||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 5, 6 ), 0.0001 );
|
||||
QGSCOMPARENEAR( radius, sqrt( 2 ) * 2, 0.0001 );
|
||||
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||
QCOMPARE( result.asWkt(), resultTest.asWkt() );
|
||||
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((7 4, 4.3 3.3, 2.3 5.3, 3 8, 5.7 8.7, 7.7 6.7, 7 4))" ) );
|
||||
|
||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING( 0 5, 2 2, 0 -5, -1 -1 )" ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
|
||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||
QCOMPARE( result.asWkt(), resultTest.asWkt() );
|
||||
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );
|
||||
|
||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 2 2, 0 -5, -1 -1 )" ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
|
||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||
QCOMPARE( result.asWkt(), resultTest.asWkt() );
|
||||
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );
|
||||
|
||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 5, 2 2, 0 -5, -1 -1 ))" ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
|
||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||
QCOMPARE( result.asWkt(), resultTest.asWkt() );
|
||||
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );
|
||||
|
||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 0 -5, 0 0 )" ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
|
||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
|
||||
QGSCOMPARENEAR( radius, 5, 0.0001 );
|
||||
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||
QCOMPARE( result.asWkt(), resultTest.asWkt() );
|
||||
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );
|
||||
|
||||
// case 3
|
||||
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT((0 0), (5 5), (0 -5), (0 5), (-5 0))" ) );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius );
|
||||
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
|
||||
QGSCOMPARENEARPOINT( center, QgsPointXY( 0.8333, 0.8333 ), 0.0001 );
|
||||
QGSCOMPARENEAR( radius, 5.8926, 0.0001 );
|
||||
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
|
||||
QCOMPARE( result.asWkt(), resultTest.asWkt() );
|
||||
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0.8 6.7, 5.9 3.8, 5.9 -2.1, 0.8 -5.1, -4.3 -2.1, -4.3 3.8, 0.8 6.7))" ) );
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user