Skip to content
Permalink
Browse files

Add test for QgsCoordinateTransform::conversionFactor

  • Loading branch information
m-kuhn committed Sep 10, 2018
1 parent 89526a0 commit 57677f6aabf15ac98fc8d968a45403e6bab07841
Showing with 38 additions and 0 deletions.
  1. +38 −0 tests/src/core/testqgscoordinatetransform.cpp
@@ -36,6 +36,8 @@ class TestQgsCoordinateTransform: public QObject
void isValid();
void isShortCircuited();
void contextShared();
void conversionFactor();
void conversionFactor_data();

private:

@@ -213,6 +215,42 @@ void TestQgsCoordinateTransform::contextShared()
QCOMPARE( copy2.sourceDestinationDatumTransforms(), expected );
}

void TestQgsCoordinateTransform::conversionFactor()
{
QFETCH( QgsCoordinateReferenceSystem, sourceCrs );
QFETCH( QgsCoordinateReferenceSystem, destCrs );
QFETCH( QgsRectangle, rect );
QFETCH( double, factor );

QgsCoordinateTransform ct( sourceCrs, destCrs, QgsProject::instance() );

// qDebug() << QString::number(ct.conversionFactor( rect ), 'g', 17) ;
QVERIFY( qgsDoubleNear( ct.conversionFactor( rect ), factor ) );
}

void TestQgsCoordinateTransform::conversionFactor_data()
{
QTest::addColumn<QgsCoordinateReferenceSystem>( "sourceCrs" );
QTest::addColumn<QgsCoordinateReferenceSystem>( "destCrs" );
QTest::addColumn<QgsRectangle>( "rect" );
QTest::addColumn<double>( "factor" );

QTest::newRow( "Different map units" )
<< QgsCoordinateReferenceSystem::fromEpsgId( 2056 )
<< QgsCoordinateReferenceSystem::fromEpsgId( 4326 )
<< QgsRectangle( 2550000, 1200000, 2550100, 1200100 )
<< 1.1223316038381985e-5;
QTest::newRow( "Same map units" )
<< QgsCoordinateReferenceSystem::fromEpsgId( 2056 )
<< QgsCoordinateReferenceSystem::fromEpsgId( 21781 )
<< QgsRectangle( 2550000, 1200000, 2550100, 1200100 )
<< 1.0000000000248837;
QTest::newRow( "Same CRS" )
<< QgsCoordinateReferenceSystem::fromEpsgId( 2056 )
<< QgsCoordinateReferenceSystem::fromEpsgId( 2056 )
<< QgsRectangle( 2550000, 1200000, 2550100, 1200100 )
<< 1.0;
}

void TestQgsCoordinateTransform::transformBoundingBox()
{

0 comments on commit 57677f6

Please sign in to comment.
You can’t perform that action at this time.