Skip to content
Permalink
Browse files

Use proj6 api for geographicCrsAuthId(), add tests

  • Loading branch information
nyalldawson committed Apr 8, 2019
1 parent 3bab21d commit d831f4e15f4ead8b952e06a6f7d1baa69c98e9bf
Showing with 20 additions and 0 deletions.
  1. +8 −0 src/core/qgscoordinatereferencesystem.cpp
  2. +12 −0 tests/src/core/testqgscoordinatereferencesystem.cpp
@@ -2428,10 +2428,18 @@ QString QgsCoordinateReferenceSystem::geographicCrsAuthId() const
{
return d->mAuthId;
}
#if PROJ_VERSION_MAJOR>=6
else if ( d->mPj )
{
QgsProjUtils::proj_pj_unique_ptr geoCrs( proj_crs_get_geodetic_crs( QgsProjContext::get(), d->mPj.get() ) );
return geoCrs ? QStringLiteral( "%1:%2" ).arg( proj_get_id_auth_name( geoCrs.get(), 0 ), proj_get_id_code( geoCrs.get(), 0 ) ) : QString();
}
#else
else if ( d->mCRS )
{
return OSRGetAuthorityName( d->mCRS, "GEOGCS" ) + QStringLiteral( ":" ) + OSRGetAuthorityCode( d->mCRS, "GEOGCS" );
}
#endif
else
{
return QString();
@@ -84,6 +84,7 @@ class TestQgsCoordinateReferenceSystem: public QObject
void projectWithCustomCrs();
void projectEPSG25833();
void geoCcsDescription();
void geographicCrsAuthId();

private:
void debugPrint( QgsCoordinateReferenceSystem &crs );
@@ -922,5 +923,16 @@ void TestQgsCoordinateReferenceSystem::geoCcsDescription()
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:4348" ) );
QCOMPARE( crs.description(), QStringLiteral( "GDA94 (geocentric)" ) );
}

void TestQgsCoordinateReferenceSystem::geographicCrsAuthId()
{
QgsCoordinateReferenceSystem crs;
crs.createFromString( QStringLiteral( "EPSG:4326" ) );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:4326" ) );
QCOMPARE( crs.geographicCrsAuthId(), QStringLiteral( "EPSG:4326" ) );
crs.createFromString( QStringLiteral( "EPSG:3825" ) );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3825" ) );
QCOMPARE( crs.geographicCrsAuthId(), QStringLiteral( "EPSG:3824" ) );
}
QGSTEST_MAIN( TestQgsCoordinateReferenceSystem )
#include "testqgscoordinatereferencesystem.moc"

0 comments on commit d831f4e

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