Skip to content

Commit

Permalink
testqgsogrutils.cpp: fix build with GDAL 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Aug 13, 2021
1 parent f61970f commit e7bd600
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions tests/src/core/testqgsogrutils.cpp
Expand Up @@ -722,30 +722,33 @@ void TestQgsOgrUtils::convertStyleString()
void TestQgsOgrUtils::ogrCrsConversion()
{
// test conversion utilities for OGR srs objects
{
const QgsCoordinateReferenceSystem crs1( QStringLiteral( "EPSG:3111" ) );
OGRSpatialReferenceH srs = QgsOgrUtils::crsToOGRSpatialReference( crs1 );
QVERIFY( srs );
const QgsCoordinateReferenceSystem crs2( QgsOgrUtils::OGRSpatialReferenceToCrs( srs ) );
// round trip should be lossless
QCOMPARE( crs1, crs2 );
OSRRelease( srs );

const QgsCoordinateReferenceSystem crs1( QStringLiteral( "EPSG:3111" ) );
OGRSpatialReferenceH srs = QgsOgrUtils::crsToOGRSpatialReference( crs1 );
QVERIFY( srs );
const QgsCoordinateReferenceSystem crs2( QgsOgrUtils::OGRSpatialReferenceToCrs( srs ) );
// round trip should be lossless
QCOMPARE( crs1, crs2 );
OSRRelease( srs );
srs = nullptr;
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,4,0)
QVERIFY( std::isnan( crs2.coordinateEpoch() ) );
#endif
}

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,4,0)
QVERIFY( std::isnan( crs2.coordinateEpoch() ) );

// test conversion with a coordinate epoch, should work on GDAL 3.4+
crs1 = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
crs1.setCoordinateEpoch( 2020.7 );
srs = QgsOgrUtils::crsToOGRSpatialReference( crs1 );
QVERIFY( srs );
crs2 = QgsCoordinateReferenceSystem( QgsOgrUtils::OGRSpatialReferenceToCrs( srs ) );
// round trip should be lossless
QCOMPARE( crs1, crs2 );
QCOMPARE( crs2.coordinateEpoch(), 2020.7 );
OSRRelease( srs );
srs = nullptr;
{
// test conversion with a coordinate epoch, should work on GDAL 3.4+
QgsCoordinateReferenceSystem crs1( QStringLiteral( "EPSG:4326" ) );
crs1.setCoordinateEpoch( 2020.7 );
OGRSpatialReferenceH srs = QgsOgrUtils::crsToOGRSpatialReference( crs1 );
QVERIFY( srs );
const QgsCoordinateReferenceSystem crs2( QgsOgrUtils::OGRSpatialReferenceToCrs( srs ) );
// round trip should be lossless
QCOMPARE( crs1, crs2 );
QCOMPARE( crs2.coordinateEpoch(), 2020.7 );
OSRRelease( srs );
}
#endif
}

Expand Down

0 comments on commit e7bd600

Please sign in to comment.