Skip to content

Commit

Permalink
Update test results for proj 6
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 3, 2019
1 parent 4fc89f7 commit 315e043
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/src/gui/testqgsdatumtransformdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ void TestQgsDatumTransformDialog::cleanup()

void TestQgsDatumTransformDialog::defaultTransform()
{
#if PROJ_VERSION_MAJOR>=6
QgsDatumTransformDialog dlg( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7844" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4283" ) ) );

QgsDatumTransformDialog::TransformInfo def = dlg.defaultDatumTransform();
QCOMPARE( def.sourceCrs.authid(), QStringLiteral( "EPSG:7844" ) );
QCOMPARE( def.destinationCrs.authid(), QStringLiteral( "EPSG:4283" ) );
QVERIFY( def.proj.startsWith( QStringLiteral( "+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0.06155 +y=-0.01087 +z=-0.04019 +rx=-0.0394924 +ry=-0.0327221 +rz=-0.03" ) ) );

// default should be initially selected
def = dlg.selectedDatumTransform();
QCOMPARE( def.sourceCrs.authid(), QStringLiteral( "EPSG:7844" ) );
QCOMPARE( def.destinationCrs.authid(), QStringLiteral( "EPSG:4283" ) );
QVERIFY( def.proj.startsWith( QStringLiteral( "+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=GRS80 +step +inv +proj=helmert +x=0.06155 +y=-0.01087 +z=-0.04019 +rx=-0.0394924 +ry=-0.0327221 +rz=-0.03" ) ) );

QgsDatumTransformDialog dlg2( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ) );
def = dlg2.defaultDatumTransform();
QCOMPARE( def.sourceCrs.authid(), QStringLiteral( "EPSG:4326" ) );
QCOMPARE( def.destinationCrs.authid(), QStringLiteral( "EPSG:26742" ) );
QVERIFY( def.proj.startsWith( QStringLiteral( "+proj=pipeline +step +proj=axisswap +order=2,1 +step +proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=push +v_3 +step +proj=cart +ellps=WGS84 +step +proj=helmert +x=8 +y=-159 +z=-175 +step +inv +proj=cart +ellps=clrk66 +step +proj=pop" ) ) );

#else
Q_NOWARN_DEPRECATED_PUSH
QgsDatumTransformDialog dlg( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) );

Expand All @@ -91,6 +112,7 @@ void TestQgsDatumTransformDialog::defaultTransform()
QCOMPARE( QgsDatumTransform::datumTransformToProj( def.destinationTransformId ), QStringLiteral( "+towgs84=-10,158,187" ) );

Q_NOWARN_DEPRECATED_POP
#endif
}

void TestQgsDatumTransformDialog::shouldAskUser()
Expand Down Expand Up @@ -118,19 +140,37 @@ void TestQgsDatumTransformDialog::applyDefaultTransform()
QgsDatumTransformDialog dlg( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7406" ) ) );
dlg.applyDefaultTransform();
QVERIFY( QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
#if PROJ_VERSION_MAJOR>=6
QVERIFY( QgsProject::instance()->transformContext().coordinateOperations().isEmpty() );
QgsProject::instance()->transformContext().addCoordinateOperation( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QStringLiteral( "some proj" ) );

#endif

QgsDatumTransformDialog dlg2( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) );
dlg2.applyDefaultTransform();

#if PROJ_VERSION_MAJOR>=6
// on proj builds, a default transform means there should be no entry in the context
QVERIFY( QgsProject::instance()->transformContext().coordinateOperations().isEmpty() );
#else
QVERIFY( !QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
QCOMPARE( QgsDatumTransform::datumTransformToProj( QgsProject::instance()->transformContext().calculateDatumTransforms( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ).sourceTransformId ), QStringLiteral( "+towgs84=-10,158,187" ) );
#endif
Q_NOWARN_DEPRECATED_POP
QgsProject::instance()->clear();
}

void TestQgsDatumTransformDialog::runDialog()
{
QgsSettings().setValue( QStringLiteral( "/projections/promptWhenMultipleTransformsExist" ), false, QgsSettings::App );
#if PROJ_VERSION_MAJOR>=6
QVERIFY( QgsDatumTransformDialog::run( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7406" ) ) ) );
QVERIFY( QgsProject::instance()->transformContext().coordinateOperations().isEmpty() );

QVERIFY( QgsDatumTransformDialog::run( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ) );
QVERIFY( QgsProject::instance()->transformContext().coordinateOperations().isEmpty() );
QgsProject::instance()->clear();
#else
Q_NOWARN_DEPRECATED_PUSH
QVERIFY( QgsDatumTransformDialog::run( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:7406" ) ) ) );
QVERIFY( QgsProject::instance()->transformContext().sourceDestinationDatumTransforms().isEmpty() );
Expand All @@ -142,6 +182,7 @@ void TestQgsDatumTransformDialog::runDialog()
Q_NOWARN_DEPRECATED_POP
QgsProject::instance()->clear();
QVERIFY( QgsDatumTransformDialog::run( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:26742" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ) ) );
#endif
}


Expand Down

0 comments on commit 315e043

Please sign in to comment.