@@ -1733,7 +1733,7 @@ bool QgsCoordinateReferenceSystem::loadWkts( QHash<int, QString> &wkts, const ch
1733
1733
if ( line.isNull () )
1734
1734
break ;
1735
1735
1736
- if ( line.startsWith ( ' #' ) )
1736
+ if ( line.trimmed (). isEmpty () || line. startsWith ( ' #' ) )
1737
1737
{
1738
1738
continue ;
1739
1739
}
@@ -1785,14 +1785,23 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )
1785
1785
if ( line.isNull () )
1786
1786
break ;
1787
1787
1788
+ if ( line.trimmed ().isEmpty () )
1789
+ continue ;
1790
+
1788
1791
int pos = line.indexOf ( ' ,' );
1789
1792
if ( pos < 0 )
1793
+ {
1794
+ qWarning ( " No id found in: %s" , qPrintable ( line ) );
1790
1795
continue ;
1796
+ }
1791
1797
1792
1798
bool ok;
1793
1799
int epsg = line.leftRef ( pos ).toInt ( &ok );
1794
1800
if ( !ok )
1801
+ {
1802
+ qWarning ( " No valid id found in: %s" , qPrintable ( line ) );
1795
1803
continue ;
1804
+ }
1796
1805
1797
1806
// some CRS are known to fail (see http://trac.osgeo.org/gdal/ticket/2900)
1798
1807
if ( epsg == 2218 || epsg == 2221 || epsg == 2296 || epsg == 2297 || epsg == 2298 || epsg == 2299 || epsg == 2300 || epsg == 2301 || epsg == 2302 ||
@@ -1904,7 +1913,13 @@ int QgsCoordinateReferenceSystem::syncDatabase()
1904
1913
if ( proj4.isEmpty () )
1905
1914
continue ;
1906
1915
1907
- sql = QStringLiteral ( " SELECT parameters,noupdate FROM tbl_srs WHERE auth_name='EPSG' AND auth_id='%1'" ).arg ( it.key () );
1916
+ QString name ( OSRIsGeographic ( crs ) ? OSRGetAttrValue ( crs, " GEOGCS" , 0 ) :
1917
+ OSRIsGeocentric ( crs ) ? OSRGetAttrValue ( crs, " GEOCCS" , 0 ) :
1918
+ OSRGetAttrValue ( crs, " PROJCS" , 0 ) );
1919
+ if ( name.isEmpty () )
1920
+ name = QObject::tr ( " Imported from GDAL" );
1921
+
1922
+ sql = QStringLiteral ( " SELECT parameters,description,noupdate FROM tbl_srs WHERE auth_name='EPSG' AND auth_id='%1'" ).arg ( it.key () );
1908
1923
statement = database.prepare ( sql, result );
1909
1924
if ( result != SQLITE_OK )
1910
1925
{
@@ -1913,22 +1928,27 @@ int QgsCoordinateReferenceSystem::syncDatabase()
1913
1928
}
1914
1929
1915
1930
QString srsProj4;
1931
+ QString srsDesc;
1916
1932
if ( statement.step () == SQLITE_ROW )
1917
1933
{
1918
1934
srsProj4 = statement.columnAsText ( 0 );
1935
+ srsDesc = statement.columnAsText ( 1 );
1919
1936
1920
- if ( statement.columnAsText ( 1 ).toInt () != 0 )
1937
+ if ( statement.columnAsText ( 2 ).toInt () != 0 )
1921
1938
{
1922
1939
continue ;
1923
1940
}
1924
1941
}
1925
1942
1926
- if ( !srsProj4.isEmpty () )
1943
+ if ( !srsProj4.isEmpty () || !srsDesc. isEmpty () )
1927
1944
{
1928
- if ( proj4 != srsProj4 )
1945
+ if ( proj4 != srsProj4 || name != srsDesc )
1929
1946
{
1930
1947
errMsg = nullptr ;
1931
- sql = QStringLiteral ( " UPDATE tbl_srs SET parameters=%1 WHERE auth_name='EPSG' AND auth_id=%2" ).arg ( quotedValue ( proj4 ) ).arg ( it.key () );
1948
+ sql = QStringLiteral ( " UPDATE tbl_srs SET parameters=%1,description=%2 WHERE auth_name='EPSG' AND auth_id=%3" )
1949
+ .arg ( quotedValue ( proj4 ) )
1950
+ .arg ( quotedValue ( name ) )
1951
+ .arg ( it.key () );
1932
1952
1933
1953
if ( sqlite3_exec ( database.get (), sql.toUtf8 (), nullptr , nullptr , &errMsg ) != SQLITE_OK )
1934
1954
{
@@ -1962,10 +1982,6 @@ int QgsCoordinateReferenceSystem::syncDatabase()
1962
1982
ellps = ellipseRegExp.cap ( 1 );
1963
1983
}
1964
1984
1965
- QString name ( OSRIsGeographic ( crs ) ? OSRGetAttrValue ( crs, " GEOGCS" , 0 ) : OSRGetAttrValue ( crs, " PROJCS" , 0 ) );
1966
- if ( name.isEmpty () )
1967
- name = QObject::tr ( " Imported from GDAL" );
1968
-
1969
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)" )
1970
1986
.arg ( quotedValue ( name ),
1971
1987
quotedValue ( projRegExp.cap ( 1 ) ),
0 commit comments