"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core/qgscoordinatereferencesystem.cpp" between
QGIS-final-3_10_11.tar.gz and QGIS-final-3_10_12.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Long-term release (3.10.x series).

qgscoordinatereferencesystem.cpp  (QGIS-final-3_10_11):qgscoordinatereferencesystem.cpp  (QGIS-final-3_10_12)
skipping to change at line 278 skipping to change at line 278
bool QgsCoordinateReferenceSystem::createFromString( const QString &definition ) bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
{ {
QgsReadWriteLocker locker( sCrsStringLock, QgsReadWriteLocker::Read ); QgsReadWriteLocker locker( sCrsStringLock, QgsReadWriteLocker::Read );
if ( !sDisableStringCache ) if ( !sDisableStringCache )
{ {
QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sStri ngCache.constFind( definition ); QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sStri ngCache.constFind( definition );
if ( crsIt != sStringCache.constEnd() ) if ( crsIt != sStringCache.constEnd() )
{ {
// found a match in the cache // found a match in the cache
*this = crsIt.value(); *this = crsIt.value();
return true; return d->mIsValid;
} }
} }
locker.unlock(); locker.unlock();
bool result = false; bool result = false;
QRegularExpression reCrsId( QStringLiteral( "^(epsg|esri|osgeo|ignf|zangi|iau2 000|postgis|internal|user)\\:(\\w+)$" ), QRegularExpression::CaseInsensitiveOpti on ); QRegularExpression reCrsId( QStringLiteral( "^(epsg|esri|osgeo|ignf|zangi|iau2 000|postgis|internal|user)\\:(\\w+)$" ), QRegularExpression::CaseInsensitiveOpti on );
QRegularExpressionMatch match = reCrsId.match( definition ); QRegularExpressionMatch match = reCrsId.match( definition );
if ( match.capturedStart() == 0 ) if ( match.capturedStart() == 0 )
{ {
QString authName = match.captured( 1 ).toLower(); QString authName = match.captured( 1 ).toLower();
skipping to change at line 388 skipping to change at line 388
bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( const QString &crs ) bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( const QString &crs )
{ {
QgsReadWriteLocker locker( sOgcLock, QgsReadWriteLocker::Read ); QgsReadWriteLocker locker( sOgcLock, QgsReadWriteLocker::Read );
if ( !sDisableOgcCache ) if ( !sDisableOgcCache )
{ {
QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sOgcC ache.constFind( crs ); QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sOgcC ache.constFind( crs );
if ( crsIt != sOgcCache.constEnd() ) if ( crsIt != sOgcCache.constEnd() )
{ {
// found a match in the cache // found a match in the cache
*this = crsIt.value(); *this = crsIt.value();
return true; return d->mIsValid;
} }
} }
locker.unlock(); locker.unlock();
QString wmsCrs = crs; QString wmsCrs = crs;
QRegExp re_uri( "http://www\\.opengis\\.net/def/crs/([^/]+).+/([^/]+)", Qt::Ca seInsensitive ); QRegExp re_uri( "http://www\\.opengis\\.net/def/crs/([^/]+).+/([^/]+)", Qt::Ca seInsensitive );
QRegExp re_urn( "urn:ogc:def:crs:([^:]+).+([^:]+)", Qt::CaseInsensitive ); QRegExp re_urn( "urn:ogc:def:crs:([^:]+).+([^:]+)", Qt::CaseInsensitive );
if ( re_uri.exactMatch( wmsCrs ) ) if ( re_uri.exactMatch( wmsCrs ) )
{ {
skipping to change at line 413 skipping to change at line 413
wmsCrs = re_urn.cap( 1 ) + ':' + re_urn.cap( 2 ); wmsCrs = re_urn.cap( 1 ) + ':' + re_urn.cap( 2 );
} }
else else
{ {
re_urn.setPattern( QStringLiteral( "(user|custom|qgis):(\\d+)" ) ); re_urn.setPattern( QStringLiteral( "(user|custom|qgis):(\\d+)" ) );
if ( re_urn.exactMatch( wmsCrs ) && createFromSrsId( re_urn.cap( 2 ).toInt() ) ) if ( re_urn.exactMatch( wmsCrs ) && createFromSrsId( re_urn.cap( 2 ).toInt() ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableOgcCache ) if ( !sDisableOgcCache )
sOgcCache.insert( crs, *this ); sOgcCache.insert( crs, *this );
return true; return d->mIsValid;
} }
} }
#if PROJ_VERSION_MAJOR>=6 #if PROJ_VERSION_MAJOR>=6
// first chance for proj 6 - scan through legacy systems and try to use authid directly // first chance for proj 6 - scan through legacy systems and try to use authid directly
const QString legacyKey = wmsCrs.toLower(); const QString legacyKey = wmsCrs.toLower();
for ( auto it = sAuthIdToQgisSrsIdMap.constBegin(); it != sAuthIdToQgisSrsIdMa p.constEnd(); ++it ) for ( auto it = sAuthIdToQgisSrsIdMap.constBegin(); it != sAuthIdToQgisSrsIdMa p.constEnd(); ++it )
{ {
if ( it.key().compare( legacyKey, Qt::CaseInsensitive ) == 0 ) if ( it.key().compare( legacyKey, Qt::CaseInsensitive ) == 0 )
{ {
const QStringList parts = it.key().split( ':' ); const QStringList parts = it.key().split( ':' );
const QString auth = parts.at( 0 ); const QString auth = parts.at( 0 );
const QString code = parts.at( 1 ); const QString code = parts.at( 1 );
if ( loadFromAuthCode( auth, code ) ) if ( loadFromAuthCode( auth, code ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableOgcCache ) if ( !sDisableOgcCache )
sOgcCache.insert( crs, *this ); sOgcCache.insert( crs, *this );
return true; return d->mIsValid;
} }
} }
} }
#endif #endif
if ( loadFromDatabase( QgsApplication::srsDatabaseFilePath(), QStringLiteral( "lower(auth_name||':'||auth_id)" ), wmsCrs.toLower() ) ) if ( loadFromDatabase( QgsApplication::srsDatabaseFilePath(), QStringLiteral( "lower(auth_name||':'||auth_id)" ), wmsCrs.toLower() ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableOgcCache ) if ( !sDisableOgcCache )
sOgcCache.insert( crs, *this ); sOgcCache.insert( crs, *this );
return true; return d->mIsValid;
} }
// NAD27 // NAD27
if ( wmsCrs.compare( QLatin1String( "CRS:27" ), Qt::CaseInsensitive ) == 0 || if ( wmsCrs.compare( QLatin1String( "CRS:27" ), Qt::CaseInsensitive ) == 0 ||
wmsCrs.compare( QLatin1String( "OGC:CRS27" ), Qt::CaseInsensitive ) == 0 ) wmsCrs.compare( QLatin1String( "OGC:CRS27" ), Qt::CaseInsensitive ) == 0 )
{ {
// TODO: verify same axis orientation // TODO: verify same axis orientation
return createFromOgcWmsCrs( QStringLiteral( "EPSG:4267" ) ); return createFromOgcWmsCrs( QStringLiteral( "EPSG:4267" ) );
} }
skipping to change at line 482 skipping to change at line 482
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableOgcCache ) if ( !sDisableOgcCache )
sOgcCache.insert( crs, *this ); sOgcCache.insert( crs, *this );
return d->mIsValid; return d->mIsValid;
} }
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableOgcCache ) if ( !sDisableOgcCache )
sOgcCache.insert( crs, QgsCoordinateReferenceSystem() ); sOgcCache.insert( crs, QgsCoordinateReferenceSystem() );
return false; return d->mIsValid;
} }
// Misc helper functions ----------------------- // Misc helper functions -----------------------
void QgsCoordinateReferenceSystem::validate() void QgsCoordinateReferenceSystem::validate()
{ {
if ( d->mIsValid || !sCustomSrsValidation ) if ( d->mIsValid || !sCustomSrsValidation )
return; return;
// try to validate using custom validation routines // try to validate using custom validation routines
skipping to change at line 512 skipping to change at line 512
bool QgsCoordinateReferenceSystem::createFromPostgisSrid( const long id ) bool QgsCoordinateReferenceSystem::createFromPostgisSrid( const long id )
{ {
QgsReadWriteLocker locker( sSrIdCacheLock, QgsReadWriteLocker::Read ); QgsReadWriteLocker locker( sSrIdCacheLock, QgsReadWriteLocker::Read );
if ( !sDisableSrIdCache ) if ( !sDisableSrIdCache )
{ {
QHash< long, QgsCoordinateReferenceSystem >::const_iterator crsIt = sSrIdCac he.constFind( id ); QHash< long, QgsCoordinateReferenceSystem >::const_iterator crsIt = sSrIdCac he.constFind( id );
if ( crsIt != sSrIdCache.constEnd() ) if ( crsIt != sSrIdCache.constEnd() )
{ {
// found a match in the cache // found a match in the cache
*this = crsIt.value(); *this = crsIt.value();
return true; return d->mIsValid;
} }
} }
locker.unlock(); locker.unlock();
#if PROJ_VERSION_MAJOR>=6 #if PROJ_VERSION_MAJOR>=6
// first chance for proj 6 - scan through legacy systems and try to use authid directly // first chance for proj 6 - scan through legacy systems and try to use authid directly
for ( auto it = sAuthIdToQgisSrsIdMap.constBegin(); it != sAuthIdToQgisSrsIdMa p.constEnd(); ++it ) for ( auto it = sAuthIdToQgisSrsIdMap.constBegin(); it != sAuthIdToQgisSrsIdMa p.constEnd(); ++it )
{ {
if ( it.value().endsWith( QStringLiteral( ",%1" ).arg( id ) ) ) if ( it.value().endsWith( QStringLiteral( ",%1" ).arg( id ) ) )
{ {
const QStringList parts = it.key().split( ':' ); const QStringList parts = it.key().split( ':' );
const QString auth = parts.at( 0 ); const QString auth = parts.at( 0 );
const QString code = parts.at( 1 ); const QString code = parts.at( 1 );
if ( loadFromAuthCode( auth, code ) ) if ( loadFromAuthCode( auth, code ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableSrIdCache ) if ( !sDisableSrIdCache )
sSrIdCache.insert( id, *this ); sSrIdCache.insert( id, *this );
return true; return d->mIsValid;
} }
} }
} }
#endif #endif
bool result = loadFromDatabase( QgsApplication::srsDatabaseFilePath(), QString Literal( "srid" ), QString::number( id ) ); bool result = loadFromDatabase( QgsApplication::srsDatabaseFilePath(), QString Literal( "srid" ), QString::number( id ) );
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableSrIdCache ) if ( !sDisableSrIdCache )
sSrIdCache.insert( id, *this ); sSrIdCache.insert( id, *this );
skipping to change at line 557 skipping to change at line 557
bool QgsCoordinateReferenceSystem::createFromSrsId( const long id ) bool QgsCoordinateReferenceSystem::createFromSrsId( const long id )
{ {
QgsReadWriteLocker locker( sCRSSrsIdLock, QgsReadWriteLocker::Read ); QgsReadWriteLocker locker( sCRSSrsIdLock, QgsReadWriteLocker::Read );
if ( !sDisableSrsIdCache ) if ( !sDisableSrsIdCache )
{ {
QHash< long, QgsCoordinateReferenceSystem >::const_iterator crsIt = sSrsIdCa che.constFind( id ); QHash< long, QgsCoordinateReferenceSystem >::const_iterator crsIt = sSrsIdCa che.constFind( id );
if ( crsIt != sSrsIdCache.constEnd() ) if ( crsIt != sSrsIdCache.constEnd() )
{ {
// found a match in the cache // found a match in the cache
*this = crsIt.value(); *this = crsIt.value();
return true; return d->mIsValid;
} }
} }
locker.unlock(); locker.unlock();
#if PROJ_VERSION_MAJOR>=6 #if PROJ_VERSION_MAJOR>=6
// first chance for proj 6 - scan through legacy systems and try to use authid directly // first chance for proj 6 - scan through legacy systems and try to use authid directly
for ( auto it = sAuthIdToQgisSrsIdMap.constBegin(); it != sAuthIdToQgisSrsIdMa p.constEnd(); ++it ) for ( auto it = sAuthIdToQgisSrsIdMap.constBegin(); it != sAuthIdToQgisSrsIdMa p.constEnd(); ++it )
{ {
if ( it.value().startsWith( QString::number( id ) + ',' ) ) if ( it.value().startsWith( QString::number( id ) + ',' ) )
{ {
const QStringList parts = it.key().split( ':' ); const QStringList parts = it.key().split( ':' );
const QString auth = parts.at( 0 ); const QString auth = parts.at( 0 );
const QString code = parts.at( 1 ); const QString code = parts.at( 1 );
if ( loadFromAuthCode( auth, code ) ) if ( loadFromAuthCode( auth, code ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableSrsIdCache ) if ( !sDisableSrsIdCache )
sSrsIdCache.insert( id, *this ); sSrsIdCache.insert( id, *this );
return true; return d->mIsValid;
} }
} }
} }
#endif #endif
bool result = loadFromDatabase( id < USER_CRS_START_ID ? QgsApplication::srsDa tabaseFilePath() : bool result = loadFromDatabase( id < USER_CRS_START_ID ? QgsApplication::srsDa tabaseFilePath() :
QgsApplication::qgisUserDatabaseFilePath(), QgsApplication::qgisUserDatabaseFilePath(),
QStringLiteral( "srs_id" ), QString::number( i d ) ); QStringLiteral( "srs_id" ), QString::number( i d ) );
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
skipping to change at line 837 skipping to change at line 837
d.detach(); d.detach();
QgsReadWriteLocker locker( sCRSWktLock, QgsReadWriteLocker::Read ); QgsReadWriteLocker locker( sCRSWktLock, QgsReadWriteLocker::Read );
if ( !sDisableWktCache ) if ( !sDisableWktCache )
{ {
QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sWktC ache.constFind( wkt ); QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sWktC ache.constFind( wkt );
if ( crsIt != sWktCache.constEnd() ) if ( crsIt != sWktCache.constEnd() )
{ {
// found a match in the cache // found a match in the cache
*this = crsIt.value(); *this = crsIt.value();
return true; return d->mIsValid;
} }
} }
locker.unlock(); locker.unlock();
d->mIsValid = false; d->mIsValid = false;
d->mProj4.clear(); d->mProj4.clear();
d->mWktPreferred.clear(); d->mWktPreferred.clear();
if ( wkt.isEmpty() ) if ( wkt.isEmpty() )
{ {
QgsDebugMsgLevel( QStringLiteral( "theWkt is uninitialized, operation failed " ), 4 ); QgsDebugMsgLevel( QStringLiteral( "theWkt is uninitialized, operation failed " ), 4 );
skipping to change at line 915 skipping to change at line 915
} }
QgsReadWriteLocker locker( sProj4CacheLock, QgsReadWriteLocker::Read ); QgsReadWriteLocker locker( sProj4CacheLock, QgsReadWriteLocker::Read );
if ( !sDisableProj4Cache ) if ( !sDisableProj4Cache )
{ {
QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sProj 4Cache.constFind( projString ); QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sProj 4Cache.constFind( projString );
if ( crsIt != sProj4Cache.constEnd() ) if ( crsIt != sProj4Cache.constEnd() )
{ {
// found a match in the cache // found a match in the cache
*this = crsIt.value(); *this = crsIt.value();
return true; return d->mIsValid;
} }
} }
locker.unlock(); locker.unlock();
// //
// Examples: // Examples:
// +proj=tmerc +lat_0=0 +lon_0=-62 +k=0.999500 +x_0=400000 +y_0=0 // +proj=tmerc +lat_0=0 +lon_0=-62 +k=0.999500 +x_0=400000 +y_0=0
// +ellps=clrk80 +towgs84=-255,-15,71,0,0,0,0 +units=m +no_defs // +ellps=clrk80 +towgs84=-255,-15,71,0,0,0,0 +units=m +no_defs
// //
// +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.337229166666664 +k_0=0.99987742 // +proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.337229166666664 +k_0=0.99987742
skipping to change at line 950 skipping to change at line 950
QString authName; QString authName;
QString authCode; QString authCode;
if ( QgsProjUtils::identifyCrs( crs.get(), authName, authCode, QgsProjUtils: :FlagMatchBoundCrsToUnderlyingSourceCrs ) ) if ( QgsProjUtils::identifyCrs( crs.get(), authName, authCode, QgsProjUtils: :FlagMatchBoundCrsToUnderlyingSourceCrs ) )
{ {
const QString authid = QStringLiteral( "%1:%2" ).arg( authName, authCode ) ; const QString authid = QStringLiteral( "%1:%2" ).arg( authName, authCode ) ;
if ( createFromOgcWmsCrs( authid ) ) if ( createFromOgcWmsCrs( authid ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableProj4Cache ) if ( !sDisableProj4Cache )
sProj4Cache.insert( projString, *this ); sProj4Cache.insert( projString, *this );
return true; return d->mIsValid;
} }
} }
} }
// try a direct match against user crses // try a direct match against user crses
QgsCoordinateReferenceSystem::RecordMap myRecord = getRecord( "select * from t bl_srs where parameters=" + QgsSqliteUtils::quotedString( myProj4String ) + " or der by deprecated" ); QgsCoordinateReferenceSystem::RecordMap myRecord = getRecord( "select * from t bl_srs where parameters=" + QgsSqliteUtils::quotedString( myProj4String ) + " or der by deprecated" );
long id = 0; long id = 0;
if ( !myRecord.empty() ) if ( !myRecord.empty() )
{ {
id = myRecord[QStringLiteral( "srs_id" )].toLong(); id = myRecord[QStringLiteral( "srs_id" )].toLong();
skipping to change at line 1602 skipping to change at line 1602
QgsProjUtils::identifyCrs( d->threadLocalProjObject(), authName, authCode ); QgsProjUtils::identifyCrs( d->threadLocalProjObject(), authName, authCode );
} }
if ( !authName.isEmpty() && !authCode.isEmpty() ) if ( !authName.isEmpty() && !authCode.isEmpty() )
{ {
if ( loadFromAuthCode( authName, authCode ) ) if ( loadFromAuthCode( authName, authCode ) )
{ {
locker.changeMode( QgsReadWriteLocker::Write ); locker.changeMode( QgsReadWriteLocker::Write );
if ( !sDisableWktCache ) if ( !sDisableWktCache )
sWktCache.insert( wkt, *this ); sWktCache.insert( wkt, *this );
return true; return d->mIsValid;
} }
} }
else else
{ {
// Still a valid CRS, just not a known one // Still a valid CRS, just not a known one
d->mIsValid = true; d->mIsValid = true;
} }
setMapUnits(); setMapUnits();
} }
#else #else
 End of changes. 14 change blocks. 
14 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)