Skip to content

Commit fb53f54

Browse files
committed
Make QgsCoordinateReferenceSystem less noisy with debug messages
1 parent e7f2f78 commit fb53f54

File tree

1 file changed

+4
-75
lines changed

1 file changed

+4
-75
lines changed

src/core/qgscoordinatereferencesystem.cpp

+4-75
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ bool QgsCoordinateReferenceSystem::createFromWkt( const QString &wkt )
595595
QgsDebugMsg( "theWkt is uninitialized, operation failed" );
596596
return d->mIsValid;
597597
}
598-
QgsDebugMsg( "wkt: " + wkt );
599598
QByteArray ba = wkt.toLatin1();
600599
const char *pWkt = ba.data();
601600

@@ -620,7 +619,6 @@ bool QgsCoordinateReferenceSystem::createFromWkt( const QString &wkt )
620619
QString authid = QStringLiteral( "%1:%2" )
621620
.arg( OSRGetAuthorityName( d->mCRS, nullptr ),
622621
OSRGetAuthorityCode( d->mCRS, nullptr ) );
623-
QgsDebugMsg( "authid recognized as " + authid );
624622
bool result = createFromOgcWmsCrs( authid );
625623
sCRSWktLock.lockForWrite();
626624
sWktCache.insert( wkt, *this );
@@ -701,16 +699,13 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
701699
// +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515.000000472 +units=m +no_defs
702700
//
703701
QString myProj4String = proj4String.trimmed();
704-
QgsDebugMsg( "proj4: " + myProj4String );
705702
d->mIsValid = false;
706703
d->mWkt.clear();
707704

708705
QRegExp myProjRegExp( "\\+proj=(\\S+)" );
709706
int myStart = myProjRegExp.indexIn( myProj4String );
710707
if ( myStart == -1 )
711708
{
712-
QgsDebugMsg( "proj string supplied has no +proj argument" );
713-
714709
sProj4CacheLock.lockForWrite();
715710
sProj4Cache.insert( proj4String, *this );
716711
sProj4CacheLock.unlock();
@@ -724,7 +719,6 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
724719
myStart = myEllipseRegExp.indexIn( myProj4String );
725720
if ( myStart == -1 )
726721
{
727-
QgsDebugMsg( "proj string supplied has no +ellps argument" );
728722
d->mEllipsoidAcronym.clear();
729723
}
730724
else
@@ -734,10 +728,6 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
734728

735729
QRegExp myAxisRegExp( "\\+a=(\\S+)" );
736730
myStart = myAxisRegExp.indexIn( myProj4String );
737-
if ( myStart == -1 )
738-
{
739-
QgsDebugMsg( "proj string supplied has no +a argument" );
740-
}
741731

742732
long mySrsId = 0;
743733
QgsCoordinateReferenceSystem::RecordMap myRecord;
@@ -849,7 +839,6 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
849839
if ( !myRecord.empty() )
850840
{
851841
mySrsId = myRecord[QStringLiteral( "srs_id" )].toLong();
852-
QgsDebugMsg( "proj4string param match search for srsid returned srsid: " + QString::number( mySrsId ) );
853842
if ( mySrsId > 0 )
854843
{
855844
createFromSrsId( mySrsId );
@@ -858,10 +847,8 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
858847
else
859848
{
860849
// Last ditch attempt to piece together what we know of the projection to find a match...
861-
QgsDebugMsg( "globbing search for srsid from this proj string" );
862850
setProj4String( myProj4String );
863851
mySrsId = findMatchingProj();
864-
QgsDebugMsg( "globbing search for srsid returned srsid: " + QString::number( mySrsId ) );
865852
if ( mySrsId > 0 )
866853
{
867854
createFromSrsId( mySrsId );
@@ -899,7 +886,6 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
899886
sqlite3_stmt *myPreparedStatement = nullptr;
900887
int myResult;
901888

902-
QgsDebugMsg( "running query: " + sql );
903889
// Get the full path name to the sqlite3 spatial reference database.
904890
myDatabaseFileName = QgsApplication::srsDatabaseFilePath();
905891
QFileInfo myInfo( myDatabaseFileName );
@@ -920,7 +906,6 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
920906
// XXX Need to free memory from the error msg if one is set
921907
if ( myResult == SQLITE_OK && sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
922908
{
923-
QgsDebugMsg( "trying system srs.db" );
924909
int myColumnCount = sqlite3_column_count( myPreparedStatement );
925910
//loop through each column in the record adding its expression name and value to the map
926911
for ( int myColNo = 0; myColNo < myColumnCount; myColNo++ )
@@ -942,7 +927,6 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
942927

943928
if ( myMap.empty() )
944929
{
945-
QgsDebugMsg( "trying user qgis.db" );
946930
sqlite3_finalize( myPreparedStatement );
947931
sqlite3_close( myDatabase );
948932

@@ -989,15 +973,6 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
989973
sqlite3_finalize( myPreparedStatement );
990974
sqlite3_close( myDatabase );
991975

992-
#ifdef QGISDEBUG
993-
QgsDebugMsg( "retrieved: " + sql );
994-
RecordMap::Iterator it;
995-
for ( it = myMap.begin(); it != myMap.end(); ++it )
996-
{
997-
QgsDebugMsgLevel( it.key() + " => " + it.value(), 2 );
998-
}
999-
#endif
1000-
1001976
return myMap;
1002977
}
1003978

@@ -1130,11 +1105,8 @@ void QgsCoordinateReferenceSystem::setProj4String( const QString& proj4String )
11301105
}
11311106
d->mWkt.clear();
11321107
setMapUnits();
1133-
1134-
#if defined(QGISDEBUG) && QGISDEBUG>=3
1135-
debugPrint();
1136-
#endif
11371108
}
1109+
11381110
void QgsCoordinateReferenceSystem::setGeographicFlag( bool geoFlag )
11391111
{
11401112
d.detach();
@@ -1187,15 +1159,12 @@ void QgsCoordinateReferenceSystem::setMapUnits()
11871159
if ( qAbs( toMeter - FEET_TO_METER ) < SMALL_NUM )
11881160
unit = QStringLiteral( "Foot" );
11891161

1190-
QgsDebugMsg( "Projection has linear units of " + unit );
1191-
11921162
if ( qgsDoubleNear( toMeter, 1.0 ) ) //Unit name for meters would be "metre"
11931163
d->mMapUnits = QgsUnitTypes::DistanceMeters;
11941164
else if ( unit == QLatin1String( "Foot" ) )
11951165
d->mMapUnits = QgsUnitTypes::DistanceFeet;
11961166
else
11971167
{
1198-
QgsDebugMsg( "Unsupported map units of " + unit );
11991168
d->mMapUnits = QgsUnitTypes::DistanceUnknownUnit;
12001169
}
12011170
}
@@ -1207,10 +1176,8 @@ void QgsCoordinateReferenceSystem::setMapUnits()
12071176
d->mMapUnits = QgsUnitTypes::DistanceDegrees;
12081177
else
12091178
{
1210-
QgsDebugMsg( "Unsupported map units of " + unit );
12111179
d->mMapUnits = QgsUnitTypes::DistanceUnknownUnit;
12121180
}
1213-
QgsDebugMsgLevel( "Projection has angular units of " + unit, 3 );
12141181
}
12151182
}
12161183

@@ -1258,19 +1225,13 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
12581225
QString myProj4String = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 1 ) ) );
12591226
if ( toProj4() == myProj4String.trimmed() )
12601227
{
1261-
QgsDebugMsg( "-------> MATCH FOUND in srs.db srsid: " + mySrsId );
12621228
// close the sqlite3 statement
12631229
sqlite3_finalize( myPreparedStatement );
12641230
sqlite3_close( myDatabase );
12651231
return mySrsId.toLong();
12661232
}
1267-
else
1268-
{
1269-
// QgsDebugMsg(QString(" Not matched : %1").arg(myProj4String));
1270-
}
12711233
}
12721234
}
1273-
QgsDebugMsg( "no match found in srs.db, trying user db now!" );
12741235
// close the sqlite3 statement
12751236
sqlite3_finalize( myPreparedStatement );
12761237
sqlite3_close( myDatabase );
@@ -1297,19 +1258,13 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
12971258
QString myProj4String = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 1 ) ) );
12981259
if ( toProj4() == myProj4String.trimmed() )
12991260
{
1300-
QgsDebugMsg( "-------> MATCH FOUND in user qgis.db srsid: " + mySrsId );
13011261
// close the sqlite3 statement
13021262
sqlite3_finalize( myPreparedStatement );
13031263
sqlite3_close( myDatabase );
13041264
return mySrsId.toLong();
13051265
}
1306-
else
1307-
{
1308-
// QgsDebugMsg(QString(" Not matched : %1").arg(myProj4String));
1309-
}
13101266
}
13111267
}
1312-
QgsDebugMsg( "no match found in user db" );
13131268

13141269
// close the sqlite3 statement
13151270
sqlite3_finalize( myPreparedStatement );
@@ -1345,7 +1300,6 @@ QString QgsCoordinateReferenceSystem::toWkt() const
13451300
bool QgsCoordinateReferenceSystem::readXml( const QDomNode & node )
13461301
{
13471302
d.detach();
1348-
QgsDebugMsg( "Reading Spatial Ref Sys from xml ------------------------!" );
13491303
bool result = true;
13501304
QDomNode srsNode = node.namedItem( QStringLiteral( "spatialrefsys" ) );
13511305

@@ -1382,27 +1336,14 @@ bool QgsCoordinateReferenceSystem::readXml( const QDomNode & node )
13821336
}
13831337
}
13841338
}
1385-
else
1386-
{
1387-
QgsDebugMsg( "Ignoring authid/epsg for user crs." );
1388-
}
13891339

1390-
if ( initialized )
1391-
{
1392-
QgsDebugMsg( "Set from auth id" );
1393-
}
1394-
else
1340+
if ( !initialized )
13951341
{
13961342
myNode = srsNode.namedItem( QStringLiteral( "proj4" ) );
13971343

1398-
if ( createFromProj4( myNode.toElement().text() ) )
1344+
if ( !createFromProj4( myNode.toElement().text() ) )
13991345
{
1400-
// createFromProj4() sets everything, including map units
1401-
QgsDebugMsg( "Setting from proj4 string" );
1402-
}
1403-
else
1404-
{
1405-
QgsDebugMsg( "Setting from elements one by one" );
1346+
// Setting from elements one by one
14061347

14071348
myNode = srsNode.namedItem( QStringLiteral( "proj4" ) );
14081349
setProj4String( myNode.toElement().text() );
@@ -1529,10 +1470,6 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int srsId )
15291470
QString myProjString;
15301471
QString mySql = QStringLiteral( "select parameters from tbl_srs where srs_id = %1 order by deprecated" ).arg( srsId );
15311472

1532-
QgsDebugMsg( "mySrsId = " + QString::number( srsId ) );
1533-
QgsDebugMsg( "USER_CRS_START_ID = " + QString::number( USER_CRS_START_ID ) );
1534-
QgsDebugMsg( "Selection sql : " + mySql );
1535-
15361473
//
15371474
// Determine if this is a user projection or a system on
15381475
// user projection defs all have srs_id >= 100000
@@ -1552,7 +1489,6 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int srsId )
15521489
{
15531490
myDatabaseFileName = QgsApplication::srsDatabaseFilePath();
15541491
}
1555-
QgsDebugMsg( "db = " + myDatabaseFileName );
15561492

15571493
sqlite3 *db = nullptr;
15581494
int rc;
@@ -1586,7 +1522,6 @@ QString QgsCoordinateReferenceSystem::proj4FromSrsId( const int srsId )
15861522

15871523
int QgsCoordinateReferenceSystem::openDatabase( const QString& path, sqlite3 **db, bool readonly )
15881524
{
1589-
QgsDebugMsgLevel( "path = " + path, 3 );
15901525
int myResult = readonly
15911526
? sqlite3_open_v2( path.toUtf8().data(), db, SQLITE_OPEN_READONLY, nullptr )
15921527
: sqlite3_open( path.toUtf8().data(), db );
@@ -1703,7 +1638,6 @@ bool QgsCoordinateReferenceSystem::saveAsUserCrs( const QString& name )
17031638
sqlite3_errmsg( myDatabase ) ) );
17041639
return false;
17051640
}
1706-
QgsDebugMsg( QString( "Update or insert sql \n%1" ).arg( mySql ) );
17071641
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
17081642

17091643
qint64 return_id;
@@ -1988,7 +1922,6 @@ int QgsCoordinateReferenceSystem::syncDatabase()
19881922
else
19891923
{
19901924
updated++;
1991-
QgsDebugMsgLevel( QString( "SQL: %1\n OLD:%2\n NEW:%3" ).arg( sql, srsProj4, proj4 ), 3 );
19921925
}
19931926
}
19941927
}
@@ -2104,7 +2037,6 @@ int QgsCoordinateReferenceSystem::syncDatabase()
21042037
if ( sqlite3_exec( database, sql.toUtf8(), nullptr, nullptr, &errMsg ) == SQLITE_OK )
21052038
{
21062039
updated++;
2107-
QgsDebugMsgLevel( QString( "SQL: %1\n OLD:%2\n NEW:%3" ).arg( sql, params, proj4 ), 3 );
21082040
}
21092041
else
21102042
{
@@ -2253,9 +2185,6 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
22532185

22542186
insert = "INSERT INTO tbl_datum_transform(" + insert + ") VALUES (" + values + ')';
22552187

2256-
QgsDebugMsgLevel( QString( "insert:%1" ).arg( insert ), 4 );
2257-
QgsDebugMsgLevel( QString( "update:%1" ).arg( update ), 4 );
2258-
22592188
CSLDestroy( fieldnames );
22602189

22612190
Q_ASSERT( idxid >= 0 );

0 commit comments

Comments
 (0)