Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Silence noisy crssync under proj 6
  • Loading branch information
nyalldawson committed Jun 11, 2019
1 parent 56f16ac commit 5855204
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -2385,6 +2385,20 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )
}
#endif

#if PROJ_VERSION_MAJOR>=6
static void sync_db_proj_logger( void * /* user_data */, int level, const char *message )
{
if ( level == PJ_LOG_ERROR )
{
QgsDebugMsgLevel( QStringLiteral( "PROJ: %1" ).arg( message ), 2 );
}
else if ( level == PJ_LOG_DEBUG )
{
QgsDebugMsgLevel( QStringLiteral( "PROJ: %1" ).arg( message ), 3 );
}
}
#endif

int QgsCoordinateReferenceSystem::syncDatabase()
{
setlocale( LC_ALL, "C" );
Expand Down Expand Up @@ -2425,6 +2439,8 @@ int QgsCoordinateReferenceSystem::syncDatabase()

#if PROJ_VERSION_MAJOR>=6
PJ_CONTEXT *pjContext = QgsProjContext::get();
// silence proj warnings
proj_log_func( pjContext, nullptr, sync_db_proj_logger );

PROJ_STRING_LIST authorities = proj_get_authorities_from_database( pjContext );

Expand All @@ -2433,7 +2449,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
for ( auto authIter = authorities; authIter && *authIter; ++authIter )
{
const QString authority( *authIter );
QgsDebugMsgLevel( QStringLiteral( "Loading authority '%1'" ).arg( authority ), 1 );
QgsDebugMsgLevel( QStringLiteral( "Loading authority '%1'" ).arg( authority ), 2 );
PROJ_STRING_LIST codes = proj_get_codes_from_database( pjContext, *authIter, PJ_TYPE_CRS, true );

QStringList allCodes;
Expand Down Expand Up @@ -2467,7 +2483,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()

if ( proj4.isEmpty() )
{
QgsDebugMsg( QStringLiteral( "No proj4 for '%1:%2'" ).arg( authority, code ) );
QgsDebugMsgLevel( QStringLiteral( "No proj4 for '%1:%2'" ).arg( authority, code ), 2 );
// satisfy not null constraint
proj4 = "";
}
Expand Down

0 comments on commit 5855204

Please sign in to comment.