Skip to content

Commit e15f7cc

Browse files
committedMay 19, 2018
crssync: also update 'deprecated' flag (fixes #18905)
1 parent 7576ae1 commit e15f7cc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,9 @@ int QgsCoordinateReferenceSystem::syncDatabase()
19191919
if ( name.isEmpty() )
19201920
name = QObject::tr( "Imported from GDAL" );
19211921

1922-
sql = QStringLiteral( "SELECT parameters,description,noupdate FROM tbl_srs WHERE auth_name='EPSG' AND auth_id='%1'" ).arg( it.key() );
1922+
bool deprecated = name.contains( QLatin1Literal( "(deprecated)" ) );
1923+
1924+
sql = QStringLiteral( "SELECT parameters,description,deprecated,noupdate FROM tbl_srs WHERE auth_name='EPSG' AND auth_id='%1'" ).arg( it.key() );
19231925
statement = database.prepare( sql, result );
19241926
if ( result != SQLITE_OK )
19251927
{
@@ -1929,25 +1931,28 @@ int QgsCoordinateReferenceSystem::syncDatabase()
19291931

19301932
QString srsProj4;
19311933
QString srsDesc;
1934+
bool srsDeprecated;
19321935
if ( statement.step() == SQLITE_ROW )
19331936
{
19341937
srsProj4 = statement.columnAsText( 0 );
19351938
srsDesc = statement.columnAsText( 1 );
1939+
srsDeprecated = statement.columnAsText( 2 ).toInt() != 0;
19361940

1937-
if ( statement.columnAsText( 2 ).toInt() != 0 )
1941+
if ( statement.columnAsText( 3 ).toInt() != 0 )
19381942
{
19391943
continue;
19401944
}
19411945
}
19421946

19431947
if ( !srsProj4.isEmpty() || !srsDesc.isEmpty() )
19441948
{
1945-
if ( proj4 != srsProj4 || name != srsDesc )
1949+
if ( proj4 != srsProj4 || name != srsDesc || deprecated != srsDeprecated )
19461950
{
19471951
errMsg = nullptr;
1948-
sql = QStringLiteral( "UPDATE tbl_srs SET parameters=%1,description=%2 WHERE auth_name='EPSG' AND auth_id=%3" )
1952+
sql = QStringLiteral( "UPDATE tbl_srs SET parameters=%1,description=%2,deprecated=%3 WHERE auth_name='EPSG' AND auth_id=%4" )
19491953
.arg( quotedValue( proj4 ) )
19501954
.arg( quotedValue( name ) )
1955+
.arg( deprecated ? 1 : 0 )
19511956
.arg( it.key() );
19521957

19531958
if ( sqlite3_exec( database.get(), sql.toUtf8(), nullptr, nullptr, &errMsg ) != SQLITE_OK )
@@ -1982,13 +1987,14 @@ int QgsCoordinateReferenceSystem::syncDatabase()
19821987
ellps = ellipseRegExp.cap( 1 );
19831988
}
19841989

1985-
sql = QStringLiteral( "INSERT INTO tbl_srs(description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) VALUES (%1,%2,%3,%4,%5,'EPSG',%5,%6,0)" )
1990+
sql = QStringLiteral( "INSERT INTO tbl_srs(description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) VALUES (%1,%2,%3,%4,%5,'EPSG',%5,%6,%7)" )
19861991
.arg( quotedValue( name ),
19871992
quotedValue( projRegExp.cap( 1 ) ),
19881993
quotedValue( ellps ),
19891994
quotedValue( proj4 ) )
19901995
.arg( it.key() )
1991-
.arg( OSRIsGeographic( crs ) );
1996+
.arg( OSRIsGeographic( crs ) )
1997+
.arg( deprecated ? 1 : 0 );
19921998

19931999
errMsg = nullptr;
19942000
if ( sqlite3_exec( database.get(), sql.toUtf8(), nullptr, nullptr, &errMsg ) == SQLITE_OK )

1 commit comments

Comments
 (1)

agiudiceandrea commented on May 24, 2018

@agiudiceandrea
Member

Thanks @jef-n!
Unfortunately, this
bool deprecated = name.contains( QLatin1Literal( "(deprecated)" ) );
for now works only for PROJCSs with GDAL 2.2 and 2.3.0, but however it solves the inconsistencies reported in #18905 (except for EPSG 102067 that has deprecated=1 but not " deprecated" in the description and was manually updated at 792ac5a setting noupdate=1).

Anyway this fix will work also for GEOGCSs in a future version of GDAL (see OSGeo/gdal#575) and hopefully for GEOCCSs (see https://lists.osgeo.org/pipermail/gdal-dev/2018-May/048495.html and OSGeo/gdal#646) solving the discrepancies between srs.db and the GDAL EPSG derived support csv files about deprecated GEOGCSs and GEOCCSs also reported in #18905.

Please sign in to comment.