Skip to content
Permalink
Browse files
Remove QgsCoordinateReferenceSystem::createFromPostgisSrid()
This method was private and only used by the Postgres provider through
friend class.
  • Loading branch information
rouault authored and nyalldawson committed May 22, 2021
1 parent 25faed2 commit 9da78ed2e4afb2347720427a857a10563f67c5ce
@@ -251,7 +251,9 @@ bool QgsCoordinateReferenceSystem::createFromId( const long id, CrsType type )
result = createFromSrsId( id );
break;
case PostgisCrsId:
result = createFromPostgisSrid( id );
Q_NOWARN_DEPRECATED_PUSH
result = createFromSrid( id );
Q_NOWARN_DEPRECATED_POP
break;
case EpsgCrsId:
result = createFromOgcWmsCrs( QStringLiteral( "EPSG:%1" ).arg( id ) );
@@ -294,7 +296,9 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
else if ( authName == QLatin1String( "postgis" ) )
{
const long id = match.captured( 2 ).toLong();
result = createFromPostgisSrid( id );
Q_NOWARN_DEPRECATED_PUSH
result = createFromSrid( id );
Q_NOWARN_DEPRECATED_POP
}
else if ( authName == QLatin1String( "esri" ) || authName == QLatin1String( "osgeo" ) || authName == QLatin1String( "ignf" ) || authName == QLatin1String( "zangi" ) || authName == QLatin1String( "iau2000" ) )
{
@@ -491,11 +495,6 @@ void QgsCoordinateReferenceSystem::validate()
}

bool QgsCoordinateReferenceSystem::createFromSrid( const long id )
{
return createFromPostgisSrid( id );
}

bool QgsCoordinateReferenceSystem::createFromPostgisSrid( const long id )
{
QgsReadWriteLocker locker( *sSrIdCacheLock(), QgsReadWriteLocker::Read );
if ( !sDisableSrIdCache )
@@ -1091,7 +1091,6 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
static const QHash< long, QgsCoordinateReferenceSystem > &srIdCache();

friend class TestQgsCoordinateReferenceSystem;
friend class QgsPostgresProvider;
friend class QgsCoordinateReferenceSystemRegistry;
friend bool CORE_EXPORT operator> ( const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2 );
friend bool CORE_EXPORT operator< ( const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2 );
@@ -365,7 +365,9 @@ void TestQgsCoordinateReferenceSystem::ogcWmsCrsCache()
void TestQgsCoordinateReferenceSystem::createFromSrid()
{
QgsCoordinateReferenceSystem myCrs;
myCrs.createFromPostgisSrid( GEOSRID );
Q_NOWARN_DEPRECATED_PUSH
myCrs.createFromSrid( GEOSRID );
Q_NOWARN_DEPRECATED_POP
debugPrint( myCrs );
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
@@ -374,30 +376,34 @@ void TestQgsCoordinateReferenceSystem::createFromSrid()

void TestQgsCoordinateReferenceSystem::sridCache()
{
Q_NOWARN_DEPRECATED_PUSH

// test that crs can be retrieved correctly from cache
QgsCoordinateReferenceSystem crs;
crs.createFromPostgisSrid( 3112 );
crs.createFromSrid( 3112 );
QVERIFY( crs.isValid() );
QCOMPARE( crs.authid(), QStringLiteral( "EPSG:3112" ) );
QVERIFY( QgsCoordinateReferenceSystem::srIdCache().contains( 3112 ) );
// a second time, so crs is fetched from cache
QgsCoordinateReferenceSystem crs2;
crs2.createFromPostgisSrid( 3112 );
crs2.createFromSrid( 3112 );
QVERIFY( crs2.isValid() );
QCOMPARE( crs2.authid(), QStringLiteral( "EPSG:3112" ) );

// invalid
QgsCoordinateReferenceSystem crs3;
QVERIFY( !crs3.createFromPostgisSrid( -3141 ) );
QVERIFY( !crs3.createFromSrid( -3141 ) );
QVERIFY( !crs3.isValid() );
QVERIFY( QgsCoordinateReferenceSystem::srIdCache().contains( -3141 ) );
// a second time, so invalid crs is fetched from cache
QgsCoordinateReferenceSystem crs4;
QVERIFY( !crs4.createFromPostgisSrid( -3141 ) );
QVERIFY( !crs4.createFromSrid( -3141 ) );
QVERIFY( !crs4.isValid() );

QgsCoordinateReferenceSystem::invalidateCache();
QVERIFY( !QgsCoordinateReferenceSystem::srIdCache().contains( 3112 ) );

Q_NOWARN_DEPRECATED_POP
}

void TestQgsCoordinateReferenceSystem::createFromWkt()
@@ -593,7 +599,9 @@ QString TestQgsCoordinateReferenceSystem::testESRIWkt( int i, QgsCoordinateRefer
void TestQgsCoordinateReferenceSystem::createFromSrId()
{
QgsCoordinateReferenceSystem myCrs;
QVERIFY( myCrs.createFromPostgisSrid( GEOSRID ) );
Q_NOWARN_DEPRECATED_PUSH
QVERIFY( myCrs.createFromSrid( GEOSRID ) );
Q_NOWARN_DEPRECATED_POP
QVERIFY( myCrs.isValid() );
QCOMPARE( myCrs.srsid(), GEOCRS_ID );
}
@@ -1235,7 +1243,9 @@ void TestQgsCoordinateReferenceSystem::customSrsValidation()
void TestQgsCoordinateReferenceSystem::postgisSrid()
{
QgsCoordinateReferenceSystem myCrs;
myCrs.createFromPostgisSrid( GEOSRID );
Q_NOWARN_DEPRECATED_PUSH
myCrs.createFromSrid( GEOSRID );
Q_NOWARN_DEPRECATED_POP
QVERIFY( myCrs.postgisSrid() == GEOSRID );
debugPrint( myCrs );
}

0 comments on commit 9da78ed

Please sign in to comment.