mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Add a WKT column to tbl_srs
proj string definitions of CRSes are lossy, so we need to gradually transition to WKT definitions instead
This commit is contained in:
parent
3d4b5fb09a
commit
4e4cd313bd
Binary file not shown.
BIN
resources/srs.db
BIN
resources/srs.db
Binary file not shown.
Binary file not shown.
@ -1886,6 +1886,7 @@ bool QgsApplication::createDatabase( QString *errorMessage )
|
||||
|
||||
// qgis.db is missing tbl_srs, create it
|
||||
if ( sqlite3_exec( database.get(),
|
||||
"DROP INDEX IF EXISTS idx_srsauthid;"
|
||||
"CREATE TABLE tbl_srs ("
|
||||
"srs_id INTEGER PRIMARY KEY,"
|
||||
"description text NOT NULL,"
|
||||
@ -1896,7 +1897,8 @@ bool QgsApplication::createDatabase( QString *errorMessage )
|
||||
"auth_name varchar,"
|
||||
"auth_id varchar,"
|
||||
"is_geo integer NOT NULL,"
|
||||
"deprecated boolean);"
|
||||
"deprecated boolean,"
|
||||
"wkt text);"
|
||||
"CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);", nullptr, nullptr, &errmsg ) != SQLITE_OK )
|
||||
{
|
||||
if ( errorMessage )
|
||||
@ -1907,6 +1909,43 @@ bool QgsApplication::createDatabase( QString *errorMessage )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// test if wkt column exists in database
|
||||
res = sqlite3_exec( database.get(), "SELECT wkt FROM tbl_srs LIMIT 0", nullptr, nullptr, &errmsg );
|
||||
if ( res != SQLITE_OK )
|
||||
{
|
||||
// need to add wkt column
|
||||
sqlite3_free( errmsg );
|
||||
if ( sqlite3_exec( database.get(),
|
||||
"DROP INDEX IF EXISTS idx_srsauthid;"
|
||||
"DROP TABLE IF EXISTS tbl_srs_bak;"
|
||||
"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,"
|
||||
"wkt text);"
|
||||
"CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
|
||||
"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", nullptr, nullptr, &errmsg ) != SQLITE_OK )
|
||||
{
|
||||
if ( errorMessage )
|
||||
{
|
||||
*errorMessage = tr( "Migration of private qgis.db failed.\n%1" ).arg( QString::fromUtf8( errmsg ) );
|
||||
}
|
||||
sqlite3_free( errmsg );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = sqlite3_exec( database.get(), "SELECT acronym FROM tbl_projection LIMIT 0", nullptr, nullptr, &errmsg );
|
||||
if ( res != SQLITE_OK )
|
||||
@ -1936,6 +1975,8 @@ bool QgsApplication::createDatabase( QString *errorMessage )
|
||||
{
|
||||
// epsg column exists => need migration
|
||||
if ( sqlite3_exec( database.get(),
|
||||
"DROP INDEX IF EXISTS idx_srsauthid;"
|
||||
"DROP TABLE IF EXISTS tbl_srs_bak;"
|
||||
"ALTER TABLE tbl_srs RENAME TO tbl_srs_bak;"
|
||||
"CREATE TABLE tbl_srs ("
|
||||
"srs_id INTEGER PRIMARY KEY,"
|
||||
@ -1947,7 +1988,8 @@ bool QgsApplication::createDatabase( QString *errorMessage )
|
||||
"auth_name varchar,"
|
||||
"auth_id varchar,"
|
||||
"is_geo integer NOT NULL,"
|
||||
"deprecated boolean);"
|
||||
"deprecated boolean,"
|
||||
"wkt text);"
|
||||
"CREATE INDEX idx_srsauthid on tbl_srs(auth_name,auth_id);"
|
||||
"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", nullptr, nullptr, &errmsg ) != SQLITE_OK )
|
||||
|
Loading…
x
Reference in New Issue
Block a user