Skip to content

Commit 47cc4f2

Browse files
committed
also sync non-EPSG crs
1 parent 5e39bf2 commit 47cc4f2

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

src/core/qgscoordinatereferencesystem.cpp

+37-1
Original file line numberDiff line numberDiff line change
@@ -1773,9 +1773,16 @@ int QgsCoordinateReferenceSystem::syncDb()
17731773
{
17741774
deleted = sqlite3_changes( database );
17751775
}
1776+
else
1777+
{
1778+
errors++;
1779+
qCritical( "Could not execute: %s [%s]\n",
1780+
sql.toLocal8Bit().constData(),
1781+
sqlite3_errmsg( database ) );
1782+
}
17761783

17771784
#if !defined(PJ_VERSION) || PJ_VERSION!=470
1778-
sql = QString( "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name<>'EPSG' WHERE NOT deprecated" );
1785+
sql = QString( "select auth_name,auth_id,parameters from tbl_srs WHERE auth_name<>'EPSG' AND NOT deprecated" );
17791786
if ( sqlite3_prepare( database, sql.toAscii(), sql.size(), &select, &tail ) == SQLITE_OK )
17801787
{
17811788
while ( sqlite3_step( select ) == SQLITE_ROW )
@@ -1806,6 +1813,28 @@ int QgsCoordinateReferenceSystem::syncDb()
18061813
proj4 = proj4.mid( input.size() );
18071814
proj4 = proj4.trimmed();
18081815
}
1816+
1817+
if ( proj4 != params )
1818+
{
1819+
sql = QString( "UPDATE tbl_srs SET parameters=%1 WHERE auth_name=%2 AND auth_id=%3" )
1820+
.arg( quotedValue( proj4 ) )
1821+
.arg( quotedValue( auth_name ) )
1822+
.arg( quotedValue( auth_id ) );
1823+
1824+
if ( sqlite3_exec( database, sql.toUtf8(), 0, 0, &errMsg ) == SQLITE_OK )
1825+
{
1826+
updated++;
1827+
QgsDebugMsgLevel( QString( "SQL: %1\n OLD:%2\n NEW:%3" ).arg( sql ).arg( params ).arg( proj4 ), 3 );
1828+
}
1829+
else
1830+
{
1831+
qCritical( "Could not execute: %s [%s/%s]\n",
1832+
sql.toLocal8Bit().constData(),
1833+
sqlite3_errmsg( database ),
1834+
errMsg ? errMsg : "(unknown error)" );
1835+
errors++;
1836+
}
1837+
}
18091838
}
18101839
else
18111840
{
@@ -1820,6 +1849,13 @@ int QgsCoordinateReferenceSystem::syncDb()
18201849
pj_free( pj );
18211850
}
18221851
}
1852+
else
1853+
{
1854+
errors++;
1855+
qCritical( "Could not execute: %s [%s]\n",
1856+
sql.toLocal8Bit().constData(),
1857+
sqlite3_errmsg( database ) );
1858+
}
18231859
#endif
18241860

18251861
OSRDestroySpatialReference( crs );

src/crssync/main.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/***************************************************************************
2-
crssync.cpp
3-
sync srs.db with proj
4-
-------------------
5-
begin : 2011
6-
copyright : (C) 2011 by Juergen E. Fischer, norBIT GmbH
7-
email : jef at norbit dot de
2+
crssync.cpp
3+
sync srs.db with proj
4+
-------------------
5+
begin : May 2011
6+
copyright : (C) 2011 by Juergen E. Fischer, norBIT GmbH
7+
email : jef at norbit dot de
88
***************************************************************************/
99

1010
/***************************************************************************
@@ -46,7 +46,7 @@ int main( int argc, char ** argv )
4646
QgsApplication::setPrefixPath( prefixPath ? prefixPath : CMAKE_INSTALL_PREFIX, TRUE );
4747
}
4848

49-
std::cout << "Synchronizing CRS database with PROJ definitions." << std::endl;
49+
std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;
5050

5151
CPLPushErrorHandler( showError );
5252

0 commit comments

Comments
 (0)