|
36 | 36 | #include "qgscircularstringv2.h"
|
37 | 37 | #include "qgsgeometrycollectionv2.h"
|
38 | 38 | #include "qgsgeometryfactory.h"
|
| 39 | +#include "qgstestutils.h" |
39 | 40 |
|
40 | 41 | //qgs unit test utility class
|
41 | 42 | #include "qgsrenderchecker.h"
|
@@ -600,19 +601,24 @@ void TestQgsGeometry::pointV2()
|
600 | 601 | QgsCoordinateReferenceSystem sourceSrs;
|
601 | 602 | sourceSrs.createFromSrid( 3994 );
|
602 | 603 | QgsCoordinateReferenceSystem destSrs;
|
603 |
| - destSrs.createFromSrid( 4326 ); |
| 604 | + destSrs.createFromSrid( 4202 ); // want a transform with ellipsoid change |
604 | 605 | QgsCoordinateTransform tr( sourceSrs, destSrs );
|
605 | 606 | QgsPointV2 p16( QgsWKBTypes::PointZM, 6374985, -3626584, 1, 2 );
|
606 | 607 | p16.transform( tr, QgsCoordinateTransform::ForwardTransform );
|
607 |
| - QVERIFY( qgsDoubleNear( p16.x(), 175.771, 0.001 ) ); |
608 |
| - QVERIFY( qgsDoubleNear( p16.y(), -39.722, 0.001 ) ); |
609 |
| - QVERIFY( qgsDoubleNear( p16.z(), 1.0, 0.001 ) ); |
| 608 | + QGSCOMPARENEAR( p16.x(), 175.771, 0.001 ); |
| 609 | + QGSCOMPARENEAR( p16.y(), -39.724, 0.001 ); |
| 610 | + QGSCOMPARENEAR( p16.z(), 1.0, 0.001 ); |
610 | 611 | QCOMPARE( p16.m(), 2.0 );
|
611 | 612 | p16.transform( tr, QgsCoordinateTransform::ReverseTransform );
|
612 |
| - QVERIFY( qgsDoubleNear( p16.x(), 6374985, 1 ) ); |
613 |
| - QVERIFY( qgsDoubleNear( p16.y(), -3626584, 1 ) ); |
614 |
| - QVERIFY( qgsDoubleNear( p16.z(), 1.0, 0.001 ) ); |
| 613 | + QGSCOMPARENEAR( p16.x(), 6374985, 1 ); |
| 614 | + QGSCOMPARENEAR( p16.y(), -3626584, 1 ); |
| 615 | + QGSCOMPARENEAR( p16.z(), 1.0, 0.001 ); |
615 | 616 | QCOMPARE( p16.m(), 2.0 );
|
| 617 | + //test with z transform |
| 618 | + p16.transform( tr, QgsCoordinateTransform::ForwardTransform, true ); |
| 619 | + QGSCOMPARENEAR( p16.z(), -19.249, 0.001 ); |
| 620 | + p16.transform( tr, QgsCoordinateTransform::ReverseTransform, true ); |
| 621 | + QGSCOMPARENEAR( p16.z(), 1.0, 0.001 ); |
616 | 622 |
|
617 | 623 | //QTransform transform
|
618 | 624 | QTransform qtr = QTransform::fromScale( 2, 3 );
|
@@ -1467,48 +1473,56 @@ void TestQgsGeometry::lineStringV2()
|
1467 | 1473 | QgsCoordinateReferenceSystem sourceSrs;
|
1468 | 1474 | sourceSrs.createFromSrid( 3994 );
|
1469 | 1475 | QgsCoordinateReferenceSystem destSrs;
|
1470 |
| - destSrs.createFromSrid( 4326 ); |
| 1476 | + destSrs.createFromSrid( 4202 ); // want a transform with ellipsoid change |
1471 | 1477 | QgsCoordinateTransform tr( sourceSrs, destSrs );
|
1472 | 1478 |
|
1473 | 1479 | // 2d CRS transform
|
1474 | 1480 | QgsLineStringV2 l21;
|
1475 | 1481 | l21.setPoints( QgsPointSequenceV2() << QgsPointV2( 6374985, -3626584 )
|
1476 | 1482 | << QgsPointV2( 6474985, -3526584 ) );
|
1477 | 1483 | l21.transform( tr, QgsCoordinateTransform::ForwardTransform );
|
1478 |
| - QVERIFY( qgsDoubleNear( l21.pointN( 0 ).x(), 175.771, 0.001 ) ); |
1479 |
| - QVERIFY( qgsDoubleNear( l21.pointN( 0 ).y(), -39.722, 0.001 ) ); |
1480 |
| - QVERIFY( qgsDoubleNear( l21.pointN( 1 ).x(), 176.959, 0.001 ) ); |
1481 |
| - QVERIFY( qgsDoubleNear( l21.pointN( 1 ).y(), -38.798, 0.001 ) ); |
1482 |
| - QVERIFY( qgsDoubleNear( l21.boundingBox().xMinimum(), 175.771, 0.001 ) ); |
1483 |
| - QVERIFY( qgsDoubleNear( l21.boundingBox().yMinimum(), -39.722, 0.001 ) ); |
1484 |
| - QVERIFY( qgsDoubleNear( l21.boundingBox().xMaximum(), 176.959, 0.001 ) ); |
1485 |
| - QVERIFY( qgsDoubleNear( l21.boundingBox().yMaximum(), -38.798, 0.001 ) ); |
| 1484 | + QGSCOMPARENEAR( l21.pointN( 0 ).x(), 175.771, 0.001 ); |
| 1485 | + QGSCOMPARENEAR( l21.pointN( 0 ).y(), -39.724, 0.001 ); |
| 1486 | + QGSCOMPARENEAR( l21.pointN( 1 ).x(), 176.959, 0.001 ); |
| 1487 | + QGSCOMPARENEAR( l21.pointN( 1 ).y(), -38.7999, 0.001 ); |
| 1488 | + QGSCOMPARENEAR( l21.boundingBox().xMinimum(), 175.771, 0.001 ); |
| 1489 | + QGSCOMPARENEAR( l21.boundingBox().yMinimum(), -39.724, 0.001 ); |
| 1490 | + QGSCOMPARENEAR( l21.boundingBox().xMaximum(), 176.959, 0.001 ); |
| 1491 | + QGSCOMPARENEAR( l21.boundingBox().yMaximum(), -38.7999, 0.001 ); |
1486 | 1492 |
|
1487 | 1493 | //3d CRS transform
|
1488 | 1494 | QgsLineStringV2 l22;
|
1489 | 1495 | l22.setPoints( QgsPointSequenceV2() << QgsPointV2( QgsWKBTypes::PointZM, 6374985, -3626584, 1, 2 )
|
1490 | 1496 | << QgsPointV2( QgsWKBTypes::PointZM, 6474985, -3526584, 3, 4 ) );
|
1491 | 1497 | l22.transform( tr, QgsCoordinateTransform::ForwardTransform );
|
1492 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 0 ).x(), 175.771, 0.001 ) ); |
1493 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 0 ).y(), -39.722, 0.001 ) ); |
1494 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 0 ).z(), 1.0, 0.001 ) ); |
| 1498 | + QGSCOMPARENEAR( l22.pointN( 0 ).x(), 175.771, 0.001 ); |
| 1499 | + QGSCOMPARENEAR( l22.pointN( 0 ).y(), -39.724, 0.001 ); |
| 1500 | + QGSCOMPARENEAR( l22.pointN( 0 ).z(), 1.0, 0.001 ); |
1495 | 1501 | QCOMPARE( l22.pointN( 0 ).m(), 2.0 );
|
1496 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 1 ).x(), 176.959, 0.001 ) ); |
1497 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 1 ).y(), -38.798, 0.001 ) ); |
1498 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 1 ).z(), 3.0, 0.001 ) ); |
| 1502 | + QGSCOMPARENEAR( l22.pointN( 1 ).x(), 176.959, 0.001 ); |
| 1503 | + QGSCOMPARENEAR( l22.pointN( 1 ).y(), -38.7999, 0.001 ); |
| 1504 | + QGSCOMPARENEAR( l22.pointN( 1 ).z(), 3.0, 0.001 ); |
1499 | 1505 | QCOMPARE( l22.pointN( 1 ).m(), 4.0 );
|
1500 | 1506 |
|
1501 | 1507 | //reverse transform
|
1502 | 1508 | l22.transform( tr, QgsCoordinateTransform::ReverseTransform );
|
1503 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 0 ).x(), 6374985, 0.01 ) ); |
1504 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 0 ).y(), -3626584, 0.01 ) ); |
1505 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 0 ).z(), 1, 0.001 ) ); |
| 1509 | + QGSCOMPARENEAR( l22.pointN( 0 ).x(), 6374985, 0.01 ); |
| 1510 | + QGSCOMPARENEAR( l22.pointN( 0 ).y(), -3626584, 0.01 ); |
| 1511 | + QGSCOMPARENEAR( l22.pointN( 0 ).z(), 1, 0.001 ); |
1506 | 1512 | QCOMPARE( l22.pointN( 0 ).m(), 2.0 );
|
1507 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 1 ).x(), 6474985, 0.01 ) ); |
1508 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 1 ).y(), -3526584, 0.01 ) ); |
1509 |
| - QVERIFY( qgsDoubleNear( l22.pointN( 1 ).z(), 3, 0.001 ) ); |
| 1513 | + QGSCOMPARENEAR( l22.pointN( 1 ).x(), 6474985, 0.01 ); |
| 1514 | + QGSCOMPARENEAR( l22.pointN( 1 ).y(), -3526584, 0.01 ); |
| 1515 | + QGSCOMPARENEAR( l22.pointN( 1 ).z(), 3, 0.001 ); |
1510 | 1516 | QCOMPARE( l22.pointN( 1 ).m(), 4.0 );
|
1511 | 1517 |
|
| 1518 | + //z value transform |
| 1519 | + l22.transform( tr, QgsCoordinateTransform::ForwardTransform, true ); |
| 1520 | + QGSCOMPARENEAR( l22.pointN( 0 ).z(), -19.249066, 0.001 ); |
| 1521 | + QGSCOMPARENEAR( l22.pointN( 1 ).z(), -21.092128, 0.001 ); |
| 1522 | + l22.transform( tr, QgsCoordinateTransform::ReverseTransform, true ); |
| 1523 | + QGSCOMPARENEAR( l22.pointN( 0 ).z(), 1.0, 0.001 ); |
| 1524 | + QGSCOMPARENEAR( l22.pointN( 1 ).z(), 3.0, 0.001 ); |
| 1525 | + |
1512 | 1526 | //QTransform transform
|
1513 | 1527 | QTransform qtr = QTransform::fromScale( 2, 3 );
|
1514 | 1528 | QgsLineStringV2 l23;
|
|
0 commit comments