[QGIS Commit] r13155 - in trunk/qgis: resources src/app src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Mar 24 20:56:02 EDT 2010


Author: jef
Date: 2010-03-24 20:56:00 -0400 (Wed, 24 Mar 2010)
New Revision: 13155

Modified:
   trunk/qgis/resources/qgis.db
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
Log:
fix #2588

Modified: trunk/qgis/resources/qgis.db
===================================================================
(Binary files differ)

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-03-24 16:37:40 UTC (rev 13154)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-03-25 00:56:00 UTC (rev 13155)
@@ -2056,7 +2056,64 @@
       return FALSE;
     }
   }
-  return TRUE;
+  else
+  {
+    // migrate if necessary
+    sqlite3 *db;
+    if ( sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().constData(), &db ) != SQLITE_OK )
+    {
+      QMessageBox::critical( this, tr( "Private qgis.db" ), tr( "Could not open qgis.db" ) );
+      return false;
+    }
+
+    char *errmsg;
+    int res = sqlite3_exec( db, "SELECT epsg FROM tbl_srs LIMIT 0", 0, 0, &errmsg );
+    if ( res == SQLITE_OK )
+    {
+      // epsg column exists => need migration
+      if ( sqlite3_exec( db,
+                         "ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
+                         "CREATE TABLE tbl_srs ("
+                         "srs_id INTEGER PRIMARY KEY,"
+                         "description text NOT NULL,"
+                         "projection_acronym text NOT NULL,"
+                         "ellipsoid_acronym NOT NULL,"
+                         "parameters text NOT NULL,"
+                         "srid integer,"
+                         "auth_name varchar,"
+                         "auth_id varchar,"
+                         "is_geo integer NOT NULL,"
+                         "deprecated boolean);"
+                         "CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
+                         "DROP VIEW vw_srs;"
+                         "CREATE VIEW vw_srs as "
+                         "select a.description as description,"
+                         "a.srs_id as srs_id,"
+                         "a.is_geo as is_geo,"
+                         "b.name as name,"
+                         "a.parameters as parameters,"
+                         "a.auth_name as auth_name,"
+                         "a.auth_id as auth_id,"
+                         "a.deprecated as deprecated"
+                         " from "
+                         "tbl_srs a inner join tbl_projection b on a.projection_acronym=b.acronym"
+                         " order by "
+                         "b.name,"
+                         "a.description;"
+                         "INSERT INTO tbl_srs(srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) SELECT srs_id,description,projection_acronym,ellipsoid_acronym,parameters,srid,'','',is_geo,0 FROM tbl_srs_bak;"
+                         "DROP TABLE tbl_srs_bak", 0, 0, &errmsg ) != SQLITE_OK
+         )
+      {
+        QMessageBox::critical( this, tr( "Private qgis.db" ), tr( "Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) ) );
+        sqlite3_free( errmsg );
+        sqlite3_close( db );
+        return false;
+      }
+    }
+
+    sqlite3_close( db );
+  }
+  return true;
 }
 
 void QgisApp::createMapTips()

Modified: trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
===================================================================
--- trunk/qgis/src/core/qgscoordinatereferencesystem.cpp	2010-03-24 16:37:40 UTC (rev 13154)
+++ trunk/qgis/src/core/qgscoordinatereferencesystem.cpp	2010-03-25 00:56:00 UTC (rev 13155)
@@ -508,7 +508,7 @@
   }
   else
   {
-    QgsDebugMsg( "trying system qgis.db" );
+    QgsDebugMsg( "trying user qgis.db" );
     sqlite3_finalize( myPreparedStatement );
     sqlite3_close( myDatabase );
 
@@ -517,7 +517,7 @@
     myFileInfo.setFile( myDatabaseFileName );
     if ( !myFileInfo.exists( ) )
     {
-      QgsDebugMsg( "users qgis.db not found" );
+      QgsDebugMsg( "user qgis.db not found" );
       return myMap;
     }
 



More information about the QGIS-commit mailing list