Skip to content
Permalink
Browse files

Make crssync quiet by default

We only need it to show up in the build log if something has gone wrong.
By default we will just happily assume that it's doing a great job in
all conscience.
  • Loading branch information
m-kuhn committed Aug 30, 2017
1 parent 3b997c2 commit 6fe6394fc7e666ea723da67e6db3622858fc16a7
Showing with 22 additions and 11 deletions.
  1. +3 −3 src/core/qgsapplication.cpp
  2. +5 −5 src/core/qgscoordinatereferencesystem.cpp
  3. +14 −3 src/crssync/main.cpp
@@ -167,9 +167,9 @@ void QgsApplication::init( QString profileFolder )
ABISYM( mRunningFromBuildDir ) = true;
ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
qDebug( "Running from build directory!" );
qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toUtf8().data() );
qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toUtf8().data() );
QgsDebugMsgLevel( QStringLiteral( "Running from build directory!" ), 4 );
QgsDebugMsgLevel( QStringLiteral( "- source directory: %1" ).arg( ABISYM( mBuildSourcePath ).toUtf8().data() ), 4 );
QgsDebugMsgLevel( QStringLiteral( "- output directory of the build: %1" ).arg( ABISYM( mBuildOutputPath ).toUtf8().data() ), 4 );
#ifdef _MSC_VER
ABISYM( mCfgIntDir ) = prefixPath.split( '/', QString::SkipEmptyParts ).last();
qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().data() );
@@ -1715,7 +1715,7 @@ QString QgsCoordinateReferenceSystem::quotedValue( QString value )
// adapted from gdal/ogr/ogr_srs_dict.cpp
bool QgsCoordinateReferenceSystem::loadWkts( QHash<int, QString> &wkts, const char *filename )
{
qDebug( "Loading %s", filename );
QgsDebugMsgLevel( QStringLiteral( "Loading %1" ).arg( filename ), 4 );
const char *pszFilename = CPLFindFile( "gdal", filename );
if ( !pszFilename )
return false;
@@ -1826,7 +1826,7 @@ bool QgsCoordinateReferenceSystem::loadIds( QHash<int, QString> &wkts )

f.close();

qDebug( "Loaded %d/%d from %s", n, l, filename.toUtf8().constData() );
QgsDebugMsgLevel( QStringLiteral( "Loaded %1/%2 from %3" ).arg( QString::number( n ), QString::number( l ), filename.toUtf8().constData() ), 4 );
}

OSRDestroySpatialReference( crs );
@@ -1841,7 +1841,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()

int inserted = 0, updated = 0, deleted = 0, errors = 0;

qDebug( "Load srs db from: %s", QgsApplication::srsDatabaseFilePath().toLocal8Bit().constData() );
QgsDebugMsgLevel( QStringLiteral( "Load srs db from: %1" ).arg( QgsApplication::srsDatabaseFilePath().toLocal8Bit().constData() ), 4 );

sqlite3 *database = nullptr;
if ( sqlite3_open( dbFilePath.toUtf8().constData(), &database ) != SQLITE_OK )
@@ -1874,7 +1874,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()
loadIds( wkts );
loadWkts( wkts, "epsg.wkt" );

qDebug( "%d WKTs loaded", wkts.count() );
QgsDebugMsgLevel( QStringLiteral( "%1 WKTs loaded" ).arg( wkts.count() ), 4 );

for ( QHash<int, QString>::const_iterator it = wkts.constBegin(); it != wkts.constEnd(); ++it )
{
@@ -2114,7 +2114,7 @@ int QgsCoordinateReferenceSystem::syncDatabase()

sqlite3_close( database );

qWarning( "CRS update (inserted:%d updated:%d deleted:%d errors:%d)", inserted, updated, deleted, errors );
QgsDebugMsgLevel( QStringLiteral( "CRS update (inserted:%1 updated:%2 deleted:%3 errors:%4)" ).arg( QString::number( inserted ), QString::number( updated ), QString::number( deleted ), QString::number( errors ) ), 4 );

if ( errors > 0 )
return -errors;
@@ -40,6 +40,16 @@ int main( int argc, char **argv )
{
QCoreApplication app( argc, argv );

const QStringList args = QCoreApplication::arguments();

bool verbose = false;

for ( const QString &arg : args )
{
if ( arg == QLatin1String( "--verbose" ) )
verbose = true;
}

QgsApplication::init();

if ( !QgsApplication::isRunningFromBuildDir() )
@@ -48,19 +58,20 @@ int main( int argc, char **argv )
QgsApplication::setPrefixPath( prefixPath ? prefixPath : CMAKE_INSTALL_PREFIX, TRUE );
}

std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;
if ( verbose )
std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;

CPLPushErrorHandler( showError );

int res = QgsCoordinateReferenceSystem::syncDatabase();

CPLPopErrorHandler();

if ( res == 0 )
if ( res == 0 && verbose )
{
std::cout << "No CRS updates were necessary." << std::endl;
}
else if ( res > 0 )
else if ( res > 0 && verbose )
{
std::cout << res << " CRSs updated." << std::endl;
}

0 comments on commit 6fe6394

Please sign in to comment.
You can’t perform that action at this time.