@@ -189,6 +189,14 @@ bool QgsSpatialRefSys::createFromSrid(long theSrid)
189
189
// Get the full path name to the sqlite3 spatial reference database.
190
190
QString myDatabaseFileName = QgsApplication::srsDbFilePath ();
191
191
192
+ QFileInfo myInfo (myDatabaseFileName);
193
+ if (!myInfo.exists ())
194
+ {
195
+ QgsDebugMsg (" QgsSpatialRefSys::createFromSrid failed : " + myDatabaseFileName +
196
+ " does not exist!" );
197
+ return false ;
198
+ }
199
+
192
200
193
201
sqlite3 *myDatabase;
194
202
const char *myTail;
@@ -582,6 +590,13 @@ QgsSpatialRefSys::RecordMap QgsSpatialRefSys::getRecord(QString theSql)
582
590
QgsDebugMsg (" QgsSpatialRefSys::getRecord...running query: " + theSql);
583
591
// Get the full path name to the sqlite3 spatial reference database.
584
592
myDatabaseFileName = QgsApplication::srsDbFilePath ();
593
+ QFileInfo myInfo (myDatabaseFileName);
594
+ if (!myInfo.exists ())
595
+ {
596
+ QgsDebugMsg (" QgsSpatialRefSys::createFromSrid failed : " + myDatabaseFileName +
597
+ " does not exist!" );
598
+ return myMap;
599
+ }
585
600
586
601
// check the db is available
587
602
myResult = openDb (myDatabaseFileName, &myDatabase);
@@ -594,6 +609,7 @@ QgsSpatialRefSys::RecordMap QgsSpatialRefSys::getRecord(QString theSql)
594
609
// XXX Need to free memory from the error msg if one is set
595
610
if (myResult == SQLITE_OK && sqlite3_step (myPreparedStatement) == SQLITE_ROW)
596
611
{
612
+ QgsDebugMsg (" QgsSpatialRefSys::getRecord...trying system srs.db" );
597
613
int myColumnCount = sqlite3_column_count (myPreparedStatement);
598
614
// loop through each column in the record adding its field name and vvalue to the map
599
615
for (int myColNo=0 ;myColNo < myColumnCount;myColNo++)
@@ -605,7 +621,7 @@ QgsSpatialRefSys::RecordMap QgsSpatialRefSys::getRecord(QString theSql)
605
621
}
606
622
else
607
623
{
608
- QgsDebugMsg (" QgsSpatialRefSys::getRecord...trying system users .db" );
624
+ QgsDebugMsg (" QgsSpatialRefSys::getRecord...trying system qgis .db" );
609
625
sqlite3_finalize (myPreparedStatement);
610
626
sqlite3_close (myDatabase);
611
627
@@ -924,7 +940,8 @@ long QgsSpatialRefSys::findMatchingProj()
924
940
}
925
941
}
926
942
}
927
- // std::cout << "QgsSpatialRefSys::findMatchingProj -------> no match found in srs.db, trying user db now!" << std::endl;
943
+ QgsLogger::warning (" QgsSpatialRefSys::findMatchingProj ------->"
944
+ " \n no match found in srs.db, trying user db now!" );
928
945
// close the sqlite3 statement
929
946
sqlite3_finalize (myPreparedStatement);
930
947
sqlite3_close (myDatabase);
0 commit comments