Skip to content
Permalink
Browse files

fix #2588

git-svn-id: http://svn.osgeo.org/qgis/trunk@13155 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 25, 2010
1 parent e62cf91 commit 812c5572e7081c3a5f07fba6a45aa2e08920a75e
Showing with 60 additions and 3 deletions.
  1. BIN resources/qgis.db
  2. +58 −1 src/app/qgisapp.cpp
  3. +2 −2 src/core/qgscoordinatereferencesystem.cpp
BIN +2 KB (110%) resources/qgis.db
Binary file not shown.
@@ -2056,7 +2056,64 @@ bool QgisApp::createDB()
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()
@@ -508,7 +508,7 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
}
else
{
QgsDebugMsg( "trying system qgis.db" );
QgsDebugMsg( "trying user qgis.db" );
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );

@@ -517,7 +517,7 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
myFileInfo.setFile( myDatabaseFileName );
if ( !myFileInfo.exists( ) )
{
QgsDebugMsg( "users qgis.db not found" );
QgsDebugMsg( "user qgis.db not found" );
return myMap;
}

0 comments on commit 812c557

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