Skip to content

Commit 9eca6b7

Browse files
author
mhugent
committed
New srs.db and code changes to save settings by proj4 string instead of qgis srsid number
git-svn-id: http://svn.osgeo.org/qgis/trunk@8720 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 25895d0 commit 9eca6b7

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

resources/srs.db

178 KB
Binary file not shown.

src/app/qgisapp.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,17 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
265265
//it in the ctor of the layer projection selector
266266

267267
QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector();
268-
long myDefaultSRS =
269-
QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectSRSID",GEOSRS_ID);
270-
mySelector->setSelectedSRSID(myDefaultSRS);
268+
proj4String = QgsProject::instance()->readEntry("SpatialRefSys","//ProjectSRSProj4String",GEOPROJ4);
269+
QgsSpatialRefSys defaultSRS;
270+
if(defaultSRS.createFromProj4(proj4String))
271+
{
272+
mySelector->setSelectedSRSID(defaultSRS.srsid());
273+
}
274+
271275
if(mySelector->exec())
272276
{
273277
QgsDebugMsg("Layer srs set from dialog: " + QString::number(mySelector->getCurrentSRSID()));
274-
srs->createFromSrsId(mySelector->getCurrentSRSID());
278+
srs->createFromProj4(mySelector->getCurrentProj4String());
275279
srs->debugPrint();
276280
}
277281
else
@@ -290,10 +294,7 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
290294
}
291295
else ///Projections/defaultBehaviour==useGlobal
292296
{
293-
// XXX TODO: Change global settings to store default CS as 'defaultSRS' not 'defaultProjectionWKT'
294-
int srs_id = mySettings.value("/Projections/defaultProjectionSRSID",(int)GEOSRS_ID).toInt();
295-
QgsDebugMsg("Layer srs set from global: " + proj4String);
296-
srs->createFromSrsId(srs_id);
297+
srs->createFromProj4(mySettings.value("/Projections/defaultProjectionString",GEOPROJ4).toString());
297298
srs->debugPrint();
298299
}
299300

src/app/qgsoptions.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
8484
{
8585
radUseGlobalProjection->setChecked(true);
8686
}
87-
mGlobalSRSID = settings.value("/Projections/defaultProjectionSRSID",(int)GEOSRS_ID).toInt();
88-
//! @todo changes this control name in gui to txtGlobalProjString
89-
QString myProjString = QgsSpatialRefSys::getProj4FromSrsId(mGlobalSRSID);
90-
txtGlobalWKT->setText(myProjString);
87+
88+
txtGlobalWKT->setText(settings.value("/Projections/defaultProjectionString",GEOPROJ4).toString());
9189

9290
// populate combo box with ellipsoids
9391
getEllipsoidList();
@@ -293,7 +291,8 @@ void QgsOptions::saveOptions()
293291
//
294292
settings.setValue("/Projections/defaultBehaviour", "useGlobal");
295293
}
296-
settings.setValue("/Projections/defaultProjectionSRSID",(int)mGlobalSRSID);
294+
295+
settings.setValue("/Projections/defaultProjectionString", txtGlobalWKT->toPlainText());
297296

298297
settings.setValue("/qgis/measure/ellipsoid", getEllipsoidAcronym(cmbEllipsoid->currentText()));
299298

@@ -367,13 +366,19 @@ void QgsOptions::on_pbnSelectProjection_clicked()
367366
{
368367
QSettings settings;
369368
QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this);
370-
mySelector->setSelectedSRSID(mGlobalSRSID);
369+
370+
//find out srs id of current proj4 string
371+
QgsSpatialRefSys refSys;
372+
if(refSys.createFromProj4(txtGlobalWKT->toPlainText()))
373+
{
374+
mySelector->setSelectedSRSID(refSys.srsid());
375+
}
376+
371377
if(mySelector->exec())
372378
{
373379
#ifdef QGISDEBUG
374380
std::cout << "------ Global Default Projection Selection Set ----------" << std::endl;
375-
#endif
376-
mGlobalSRSID = mySelector->getCurrentSRSID();
381+
#endif
377382
//! @todo changes this control name in gui to txtGlobalProjString
378383
txtGlobalWKT->setText(mySelector->getCurrentProj4String());
379384
#ifdef QGISDEBUG

src/app/qgsoptions.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
9797
QWidget *qparent;
9898

9999
//!Global default projection used for new layers added that have no projection
100-
long mGlobalSRSID;
100+
//long mGlobalSRSID;
101+
102+
//!Default proj4 string used for new layers added that have no projection
103+
QString mGlobalProj4String;
101104

102105
};
103106

src/app/qgsserversourceselect.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,12 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
434434

435435
mySelector->setOgcWmsCrsFilter(crsFilter);
436436

437-
long myDefaultSRS = QgsProject::instance()->readNumEntry("SpatialRefSys", "/ProjectSRSID", GEOSRS_ID);
438-
439-
mySelector->setSelectedSRSID(myDefaultSRS);
437+
QString myDefaultProjString = QgsProject::instance()->readEntry("SpatialRefSys", "/ProjectSRSProj4String", GEOPROJ4);
438+
QgsSpatialRefSys defaultSRS;
439+
if(defaultSRS.createFromProj4(myDefaultProjString))
440+
{
441+
mySelector->setSelectedSRSID(defaultSRS.srsid());
442+
}
440443

441444
if (mySelector->exec())
442445
{

0 commit comments

Comments
 (0)