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
This commit is contained in:
mhugent 2008-07-07 07:40:10 +00:00
parent 25895d0269
commit 9eca6b7c93
5 changed files with 32 additions and 20 deletions

Binary file not shown.

View File

@ -265,13 +265,17 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
//it in the ctor of the layer projection selector //it in the ctor of the layer projection selector
QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(); QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector();
long myDefaultSRS = proj4String = QgsProject::instance()->readEntry("SpatialRefSys","//ProjectSRSProj4String",GEOPROJ4);
QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectSRSID",GEOSRS_ID); QgsSpatialRefSys defaultSRS;
mySelector->setSelectedSRSID(myDefaultSRS); if(defaultSRS.createFromProj4(proj4String))
{
mySelector->setSelectedSRSID(defaultSRS.srsid());
}
if(mySelector->exec()) if(mySelector->exec())
{ {
QgsDebugMsg("Layer srs set from dialog: " + QString::number(mySelector->getCurrentSRSID())); QgsDebugMsg("Layer srs set from dialog: " + QString::number(mySelector->getCurrentSRSID()));
srs->createFromSrsId(mySelector->getCurrentSRSID()); srs->createFromProj4(mySelector->getCurrentProj4String());
srs->debugPrint(); srs->debugPrint();
} }
else else
@ -290,10 +294,7 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
} }
else ///Projections/defaultBehaviour==useGlobal else ///Projections/defaultBehaviour==useGlobal
{ {
// XXX TODO: Change global settings to store default CS as 'defaultSRS' not 'defaultProjectionWKT' srs->createFromProj4(mySettings.value("/Projections/defaultProjectionString",GEOPROJ4).toString());
int srs_id = mySettings.value("/Projections/defaultProjectionSRSID",(int)GEOSRS_ID).toInt();
QgsDebugMsg("Layer srs set from global: " + proj4String);
srs->createFromSrsId(srs_id);
srs->debugPrint(); srs->debugPrint();
} }

View File

@ -84,10 +84,8 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
{ {
radUseGlobalProjection->setChecked(true); radUseGlobalProjection->setChecked(true);
} }
mGlobalSRSID = settings.value("/Projections/defaultProjectionSRSID",(int)GEOSRS_ID).toInt();
//! @todo changes this control name in gui to txtGlobalProjString txtGlobalWKT->setText(settings.value("/Projections/defaultProjectionString",GEOPROJ4).toString());
QString myProjString = QgsSpatialRefSys::getProj4FromSrsId(mGlobalSRSID);
txtGlobalWKT->setText(myProjString);
// populate combo box with ellipsoids // populate combo box with ellipsoids
getEllipsoidList(); getEllipsoidList();
@ -293,7 +291,8 @@ void QgsOptions::saveOptions()
// //
settings.setValue("/Projections/defaultBehaviour", "useGlobal"); settings.setValue("/Projections/defaultBehaviour", "useGlobal");
} }
settings.setValue("/Projections/defaultProjectionSRSID",(int)mGlobalSRSID);
settings.setValue("/Projections/defaultProjectionString", txtGlobalWKT->toPlainText());
settings.setValue("/qgis/measure/ellipsoid", getEllipsoidAcronym(cmbEllipsoid->currentText())); settings.setValue("/qgis/measure/ellipsoid", getEllipsoidAcronym(cmbEllipsoid->currentText()));
@ -367,13 +366,19 @@ void QgsOptions::on_pbnSelectProjection_clicked()
{ {
QSettings settings; QSettings settings;
QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this); QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this);
mySelector->setSelectedSRSID(mGlobalSRSID);
//find out srs id of current proj4 string
QgsSpatialRefSys refSys;
if(refSys.createFromProj4(txtGlobalWKT->toPlainText()))
{
mySelector->setSelectedSRSID(refSys.srsid());
}
if(mySelector->exec()) if(mySelector->exec())
{ {
#ifdef QGISDEBUG #ifdef QGISDEBUG
std::cout << "------ Global Default Projection Selection Set ----------" << std::endl; std::cout << "------ Global Default Projection Selection Set ----------" << std::endl;
#endif #endif
mGlobalSRSID = mySelector->getCurrentSRSID();
//! @todo changes this control name in gui to txtGlobalProjString //! @todo changes this control name in gui to txtGlobalProjString
txtGlobalWKT->setText(mySelector->getCurrentProj4String()); txtGlobalWKT->setText(mySelector->getCurrentProj4String());
#ifdef QGISDEBUG #ifdef QGISDEBUG

View File

@ -97,7 +97,10 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
QWidget *qparent; QWidget *qparent;
//!Global default projection used for new layers added that have no projection //!Global default projection used for new layers added that have no projection
long mGlobalSRSID; //long mGlobalSRSID;
//!Default proj4 string used for new layers added that have no projection
QString mGlobalProj4String;
}; };

View File

@ -434,9 +434,12 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
mySelector->setOgcWmsCrsFilter(crsFilter); mySelector->setOgcWmsCrsFilter(crsFilter);
long myDefaultSRS = QgsProject::instance()->readNumEntry("SpatialRefSys", "/ProjectSRSID", GEOSRS_ID); QString myDefaultProjString = QgsProject::instance()->readEntry("SpatialRefSys", "/ProjectSRSProj4String", GEOPROJ4);
QgsSpatialRefSys defaultSRS;
mySelector->setSelectedSRSID(myDefaultSRS); if(defaultSRS.createFromProj4(myDefaultProjString))
{
mySelector->setSelectedSRSID(defaultSRS.srsid());
}
if (mySelector->exec()) if (mySelector->exec())
{ {