Skip to content

Commit fb98e13

Browse files
author
g_j_m
committed
Fix for ticket #122 (projection set incorrectly for some raster
layers). The way that the raster layer sets it's srs is a bit complex - hopefully these changes fix the problem without introducing other problems (seems ok from the testing that I've done). git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5726 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 842e0a7 commit fb98e13

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/gui/qgsspatialrefsys.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ void QgsSpatialRefSys::validate()
173173
return;
174174
}
175175
}
176+
176177
QSettings mySettings;
177178
QString myDefaultProjectionOption =
178179
mySettings.readEntry("/Projections/defaultBehaviour");
180+
179181
if (myDefaultProjectionOption=="prompt")
180182
{
181183
//@note this class is not a descendent of QWidget so we cant pass
@@ -188,6 +190,8 @@ void QgsSpatialRefSys::validate()
188190
if(mySelector->exec())
189191
{
190192
createFromSrsId(mySelector->getCurrentSRSID());
193+
delete mySelector;
194+
return;
191195
}
192196
else
193197
{
@@ -200,10 +204,12 @@ void QgsSpatialRefSys::validate()
200204
// XXX TODO: Change project to store selected CS as 'projectSRS' not 'selectedWKT'
201205
mProj4String = QgsProject::instance()->readEntry("SpatialRefSys","//ProjectSRSProj4String",GEOPROJ4);
202206
}
203-
else ///Projections/defaultBehaviour==useDefault
207+
else ///Projections/defaultBehaviour==useGlobal
204208
{
205209
// XXX TODO: Change global settings to store default CS as 'defaultSRS' not 'defaultProjectionWKT'
206-
mProj4String = mySettings.readEntry("/Projections/defaultSRS",GEOPROJ4);
210+
int srs_id = mySettings.readNumEntry("/Projections/defaultProjectionSRSID",GEOSRS_ID);
211+
createFromSrsId(srs_id);
212+
return;
207213
}
208214

209215
//
@@ -222,7 +228,9 @@ void QgsSpatialRefSys::validate()
222228
//default to proj 4..if all else fails we will use that for this srs
223229
mProj4String = GEOPROJ4;
224230
}
231+
225232
createFromProj4(mProj4String);
233+
226234
return;
227235
}
228236

@@ -460,6 +468,7 @@ bool QgsSpatialRefSys::createFromSrsId (long theSrsId)
460468
mGeoFlag = (geo == 0 ? false : true);
461469
setMapUnits();
462470
mIsValidFlag = true;
471+
463472
}
464473
else
465474
{

src/raster/qgsrasterlayer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ wish to see edbug messages printed to stdout.
8888
#include <QDomElement>
8989
#include <QFrame>
9090
#include <QPixmap>
91-
91+
#include <QSettings>
9292
/*
9393
*
9494
* New includes that will convert this class to a data provider interface
@@ -690,8 +690,15 @@ QString QgsRasterLayer::getProjectionWKT()
690690
{
691691
//try to get the gcp srs from the raster layer if available
692692
myWKTString=QString(gdalDataset->GetGCPProjection());
693+
mySRS.createFromWkt(myWKTString);
694+
if (!mySRS.isValid())
695+
{
696+
// set to default here?
697+
QSettings settings;
698+
int srsid = settings.readNumEntry("Projections/defaultProjectionSRSID", 4326);
699+
mySRS.createFromId(srsid, QgsSpatialRefSys::QGIS_SRSID);
700+
}
693701
}
694-
695702

696703
return myWKTString;
697704
}

0 commit comments

Comments
 (0)