Skip to content

Commit 38cc570

Browse files
committedSep 19, 2017
Improve test cases
1 parent 6f5d9c9 commit 38cc570

File tree

1 file changed

+42
-43
lines changed

1 file changed

+42
-43
lines changed
 

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,35 +1558,34 @@ void TestQgsGeometry::circularString()
15581558

15591559
//2d line
15601560
l24.setPoints( QgsPointSequence() << QgsPoint( 1, 2 )
1561-
<< QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) );
1562-
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 6.0, 7.0 ) ) );
1561+
<< QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) );
1562+
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 4.0, 7.0 ) ) );
15631563
QCOMPARE( l24.numPoints(), 5 );
15641564
QVERIFY( !l24.is3D() );
15651565
QVERIFY( !l24.isMeasure() );
15661566
QCOMPARE( l24.wkbType(), QgsWkbTypes::CircularString );
15671567
QCOMPARE( l24.pointN( 0 ), QgsPoint( 1.0, 2.0 ) );
1568-
QCOMPARE( l24.pointN( 1 ), QgsPoint( 6.0, 7.0 ) );
1569-
// note - the next point is just testing current behavior - I do NOT know if this is the correct value!
1570-
QGSCOMPARENEAR( l24.pointN( 2 ).x(), -0.66, 0.01 );
1571-
QGSCOMPARENEAR( l24.pointN( 2 ).y(), -0.745, 0.01 );
1568+
QCOMPARE( l24.pointN( 1 ), QgsPoint( 4.0, 7.0 ) );
1569+
QGSCOMPARENEAR( l24.pointN( 2 ).x(), 7.192236, 0.01 );
1570+
QGSCOMPARENEAR( l24.pointN( 2 ).y(), 9.930870, 0.01 );
15721571
QCOMPARE( l24.pointN( 3 ), QgsPoint( 11.0, 12.0 ) );
1573-
QCOMPARE( l24.pointN( 4 ), QgsPoint( 21.0, 22.0 ) );
1572+
QCOMPARE( l24.pointN( 4 ), QgsPoint( 1.0, 22.0 ) );
15741573

15751574
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( 8.0, 9.0 ) ) );
1576-
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 2 ), QgsPoint( 18.0, 19.0 ) ) );
1575+
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 2 ), QgsPoint( 18.0, 16.0 ) ) );
15771576
QCOMPARE( l24.numPoints(), 9 );
15781577
QCOMPARE( l24.pointN( 0 ), QgsPoint( 1.0, 2.0 ) );
1579-
QGSCOMPARENEAR( l24.pointN( 1 ).x(), -0.63, 0.01 );
1580-
QGSCOMPARENEAR( l24.pointN( 1 ).y(), -0.774, 0.01 );
1578+
QGSCOMPARENEAR( l24.pointN( 1 ).x(), 4.363083, 0.01 );
1579+
QGSCOMPARENEAR( l24.pointN( 1 ).y(), 5.636917, 0.01 );
15811580
QCOMPARE( l24.pointN( 2 ), QgsPoint( 8.0, 9.0 ) );
1582-
QCOMPARE( l24.pointN( 3 ), QgsPoint( 18.0, 19.0 ) );
1583-
QGSCOMPARENEAR( l24.pointN( 4 ).x(), -0.658, 0.01 );
1584-
QGSCOMPARENEAR( l24.pointN( 4 ).y(), -0.753, 0.01 );
1585-
QCOMPARE( l24.pointN( 5 ), QgsPoint( 6.0, 7.0 ) );
1586-
QGSCOMPARENEAR( l24.pointN( 6 ).x(), -0.666, 0.01 );
1587-
QGSCOMPARENEAR( l24.pointN( 6 ).y(), -0.745, 0.01 );
1581+
QCOMPARE( l24.pointN( 3 ), QgsPoint( 18.0, 16.0 ) );
1582+
QGSCOMPARENEAR( l24.pointN( 4 ).x(), 5.876894, 0.01 );
1583+
QGSCOMPARENEAR( l24.pointN( 4 ).y(), 8.246211, 0.01 );
1584+
QCOMPARE( l24.pointN( 5 ), QgsPoint( 4.0, 7.0 ) );
1585+
QGSCOMPARENEAR( l24.pointN( 6 ).x(), 7.192236, 0.01 );
1586+
QGSCOMPARENEAR( l24.pointN( 6 ).y(), 9.930870, 0.01 );
15881587
QCOMPARE( l24.pointN( 7 ), QgsPoint( 11.0, 12.0 ) );
1589-
QCOMPARE( l24.pointN( 8 ), QgsPoint( 21.0, 22.0 ) );
1588+
QCOMPARE( l24.pointN( 8 ), QgsPoint( 1.0, 22.0 ) );
15901589

15911590
//insert vertex at end
15921591
QVERIFY( !l24.insertVertex( QgsVertexId( 0, 0, 9 ), QgsPoint( 31.0, 32.0 ) ) );
@@ -1615,11 +1614,11 @@ void TestQgsGeometry::circularString()
16151614

16161615
//insert 4d vertex in 2d line
16171616
l24.setPoints( QgsPointSequence() << QgsPoint( 1, 2 )
1618-
<< QgsPoint( 11, 12 ) << QgsPoint( 21, 22 ) );
1619-
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( QgsWkbTypes::PointZM, 101, 102, 103, 104 ) ) );
1617+
<< QgsPoint( 11, 12 ) << QgsPoint( 1, 22 ) );
1618+
QVERIFY( l24.insertVertex( QgsVertexId( 0, 0, 1 ), QgsPoint( QgsWkbTypes::PointZM, 2, 4, 103, 104 ) ) );
16201619
QCOMPARE( l24.numPoints(), 5 );
16211620
QCOMPARE( l24.wkbType(), QgsWkbTypes::CircularString );
1622-
QCOMPARE( l24.pointN( 1 ), QgsPoint( QgsWkbTypes::Point, 101, 102 ) );
1621+
QCOMPARE( l24.pointN( 1 ), QgsPoint( QgsWkbTypes::Point, 2, 4 ) );
16231622

16241623
//move vertex
16251624

@@ -6353,27 +6352,27 @@ void TestQgsGeometry::curvePolygon()
63536352
QgsRectangle bBox = boundingBoxPoly.boundingBox(); //no crash!
63546353

63556354
ext = new QgsCircularString();
6356-
ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 )
6357-
<< QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) );
6355+
ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 10, 2 ) << QgsPoint( 0, 18, 3 )
6356+
<< QgsPoint( -1, 4, 4 ) << QgsPoint( 0, 0, 1 ) );
63586357
boundingBoxPoly.setExteriorRing( ext );
63596358
bBox = boundingBoxPoly.boundingBox();
6360-
QGSCOMPARENEAR( bBox.xMinimum(), 0, 0.001 );
6361-
QGSCOMPARENEAR( bBox.xMaximum(), 2, 0.001 );
6362-
QGSCOMPARENEAR( bBox.yMinimum(), 0, 0.001 );
6363-
QGSCOMPARENEAR( bBox.yMaximum(), 0.5, 0.001 );
6359+
QGSCOMPARENEAR( bBox.xMinimum(), -1.435273, 0.001 );
6360+
QGSCOMPARENEAR( bBox.xMaximum(), 1.012344, 0.001 );
6361+
QGSCOMPARENEAR( bBox.yMinimum(), 0.000000, 0.001 );
6362+
QGSCOMPARENEAR( bBox.yMaximum(), 18, 0.001 );
63646363

63656364
//surfaceToPolygon
63666365
QgsCurvePolygon p12a;
63676366
std::unique_ptr< QgsPolygonV2 > surface( p12a.surfaceToPolygon() );
63686367
QVERIFY( surface->isEmpty() );
63696368

63706369
ext = new QgsCircularString();
6371-
ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 0 )
6372-
<< QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) );
6370+
ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 3 ) << QgsPoint( 2, 4 )
6371+
<< QgsPoint( -1, 5 ) << QgsPoint( 0, 6 ) );
63736372
p12a.setExteriorRing( ext );
63746373
surface.reset( p12a.surfaceToPolygon() );
63756374
QCOMPARE( surface->wkbType(), QgsWkbTypes::Polygon );
6376-
QCOMPARE( surface->exteriorRing()->nCoordinates(), 110 );
6375+
QCOMPARE( surface->exteriorRing()->nCoordinates(), 290 );
63776376
QVERIFY( surface->exteriorRing()->isClosed() );
63786377
// too many vertices to actually check the result, let's just make sure the bounding boxes are similar
63796378
QgsRectangle r1 = ext->boundingBox();
@@ -6389,7 +6388,7 @@ void TestQgsGeometry::curvePolygon()
63896388
p12a.addInteriorRing( ring );
63906389
surface.reset( p12a.surfaceToPolygon() );
63916390
QCOMPARE( surface->wkbType(), QgsWkbTypes::Polygon );
6392-
QCOMPARE( surface->exteriorRing()->nCoordinates(), 110 );
6391+
QCOMPARE( surface->exteriorRing()->nCoordinates(), 290 );
63936392
QVERIFY( surface->exteriorRing()->isClosed() );
63946393
QCOMPARE( surface->numInteriorRings(), 1 );
63956394
// too many vertices to actually check the result, let's just make sure the bounding boxes are similar
@@ -6406,28 +6405,28 @@ void TestQgsGeometry::curvePolygon()
64066405
QVERIFY( surface->isEmpty() );
64076406

64086407
ext = new QgsCircularString();
6409-
ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 0 ) << QgsPoint( 2, 0 )
6410-
<< QgsPoint( 1, 0.5 ) << QgsPoint( 0, 0 ) );
6408+
ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 1, 10 ) << QgsPoint( 0, 18 )
6409+
<< QgsPoint( -1, 4 ) << QgsPoint( 0, 0 ) );
64116410
p12a.setExteriorRing( ext );
64126411
surface.reset( p12a.toPolygon() );
64136412
QCOMPARE( surface->wkbType(), QgsWkbTypes::Polygon );
6414-
QCOMPARE( surface->exteriorRing()->nCoordinates(), 110 );
6413+
QCOMPARE( surface->exteriorRing()->nCoordinates(), 64 );
64156414
QVERIFY( surface->exteriorRing()->isClosed() );
64166415
// too many vertices to actually check the result, let's just make sure the bounding boxes are similar
64176416
r1 = ext->boundingBox();
64186417
r2 = surface->exteriorRing()->boundingBox();
6419-
QGSCOMPARENEAR( r1.xMinimum(), r2.xMinimum(), 0.0001 );
6420-
QGSCOMPARENEAR( r1.xMaximum(), r2.xMaximum(), 0.0001 );
6421-
QGSCOMPARENEAR( r1.yMinimum(), r2.yMinimum(), 0.0001 );
6422-
QGSCOMPARENEAR( r1.yMaximum(), r2.yMaximum(), 0.0001 );
6418+
QGSCOMPARENEAR( r1.xMinimum(), r2.xMinimum(), 0.01 );
6419+
QGSCOMPARENEAR( r1.xMaximum(), r2.xMaximum(), 0.01 );
6420+
QGSCOMPARENEAR( r1.yMinimum(), r2.yMinimum(), 0.01 );
6421+
QGSCOMPARENEAR( r1.yMaximum(), r2.yMaximum(), 0.01 );
64236422
ring = new QgsCircularString();
64246423
ring->setPoints( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointZM, 1, 1, 1, 2 )
64256424
<< QgsPoint( QgsWkbTypes::PointZM, 1, 9, 2, 3 ) << QgsPoint( QgsWkbTypes::PointZM, 9, 9, 3, 6 )
64266425
<< QgsPoint( QgsWkbTypes::PointZM, 9, 1, 4, 4 ) << QgsPoint( QgsWkbTypes::PointZM, 1, 1, 1, 7 ) );
64276426
p12a.addInteriorRing( ring );
64286427
surface.reset( p12a.toPolygon() );
64296428
QCOMPARE( surface->wkbType(), QgsWkbTypes::Polygon );
6430-
QCOMPARE( surface->exteriorRing()->nCoordinates(), 110 );
6429+
QCOMPARE( surface->exteriorRing()->nCoordinates(), 64 );
64316430
QVERIFY( surface->exteriorRing()->isClosed() );
64326431
QCOMPARE( surface->numInteriorRings(), 1 );
64336432
// too many vertices to actually check the result, let's just make sure the bounding boxes are similar
@@ -6721,15 +6720,15 @@ void TestQgsGeometry::curvePolygon()
67216720

67226721
// add interior rings
67236722
QgsCircularString removeRingsRing1;
6724-
removeRingsRing1.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 0, 2 ) << QgsPoint( 0.2, 0, 3 )
6725-
<< QgsPoint( 0.1, 0.05, 4 ) << QgsPoint( 0, 0, 1 ) );
6723+
removeRingsRing1.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.1, 1, 2 ) << QgsPoint( 0, 2, 3 )
6724+
<< QgsPoint( -0.1, 1.2, 4 ) << QgsPoint( 0, 0, 1 ) );
67266725
QgsCircularString removeRingsRing2;
6727-
removeRingsRing2.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 1, 0, 2 ) << QgsPoint( 2, 0, 3 )
6728-
<< QgsPoint( 1, 0.5, 4 ) << QgsPoint( 0, 0, 1 ) );
6726+
removeRingsRing2.setPoints( QgsPointSequence() << QgsPoint( 0, 0, 1 ) << QgsPoint( 0.01, 0.1, 2 ) << QgsPoint( 0, 0.2, 3 )
6727+
<< QgsPoint( -0.01, 0.12, 4 ) << QgsPoint( 0, 0, 1 ) );
67296728
removeRings1.setInteriorRings( QList< QgsCurve * >() << removeRingsRing1.clone() << removeRingsRing2.clone() );
67306729

67316730
// remove ring with size filter
6732-
removeRings1.removeInteriorRings( 0.1 );
6731+
removeRings1.removeInteriorRings( 0.05 );
67336732
QCOMPARE( removeRings1.numInteriorRings(), 1 );
67346733

67356734
// remove ring with no size filter

0 commit comments

Comments
 (0)
Please sign in to comment.