@@ -1919,7 +1919,9 @@ int QgsCoordinateReferenceSystem::syncDatabase()
1919
1919
if ( name.isEmpty () )
1920
1920
name = QObject::tr ( " Imported from GDAL" );
1921
1921
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 () );
1923
1925
statement = database.prepare ( sql, result );
1924
1926
if ( result != SQLITE_OK )
1925
1927
{
@@ -1929,25 +1931,28 @@ int QgsCoordinateReferenceSystem::syncDatabase()
1929
1931
1930
1932
QString srsProj4;
1931
1933
QString srsDesc;
1934
+ bool srsDeprecated;
1932
1935
if ( statement.step () == SQLITE_ROW )
1933
1936
{
1934
1937
srsProj4 = statement.columnAsText ( 0 );
1935
1938
srsDesc = statement.columnAsText ( 1 );
1939
+ srsDeprecated = statement.columnAsText ( 2 ).toInt () != 0 ;
1936
1940
1937
- if ( statement.columnAsText ( 2 ).toInt () != 0 )
1941
+ if ( statement.columnAsText ( 3 ).toInt () != 0 )
1938
1942
{
1939
1943
continue ;
1940
1944
}
1941
1945
}
1942
1946
1943
1947
if ( !srsProj4.isEmpty () || !srsDesc.isEmpty () )
1944
1948
{
1945
- if ( proj4 != srsProj4 || name != srsDesc )
1949
+ if ( proj4 != srsProj4 || name != srsDesc || deprecated != srsDeprecated )
1946
1950
{
1947
1951
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 " )
1949
1953
.arg ( quotedValue ( proj4 ) )
1950
1954
.arg ( quotedValue ( name ) )
1955
+ .arg ( deprecated ? 1 : 0 )
1951
1956
.arg ( it.key () );
1952
1957
1953
1958
if ( sqlite3_exec ( database.get (), sql.toUtf8 (), nullptr , nullptr , &errMsg ) != SQLITE_OK )
@@ -1982,13 +1987,14 @@ int QgsCoordinateReferenceSystem::syncDatabase()
1982
1987
ellps = ellipseRegExp.cap ( 1 );
1983
1988
}
1984
1989
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 )" )
1986
1991
.arg ( quotedValue ( name ),
1987
1992
quotedValue ( projRegExp.cap ( 1 ) ),
1988
1993
quotedValue ( ellps ),
1989
1994
quotedValue ( proj4 ) )
1990
1995
.arg ( it.key () )
1991
- .arg ( OSRIsGeographic ( crs ) );
1996
+ .arg ( OSRIsGeographic ( crs ) )
1997
+ .arg ( deprecated ? 1 : 0 );
1992
1998
1993
1999
errMsg = nullptr ;
1994
2000
if ( sqlite3_exec ( database.get (), sql.toUtf8 (), nullptr , nullptr , &errMsg ) == SQLITE_OK )
1 commit comments
agiudiceandrea commentedon May 24, 2018
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.