Skip to content

Commit

Permalink
Fix for ticket #122 (projection set incorrectly for some raster
Browse files Browse the repository at this point in the history
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
  • Loading branch information
g_j_m committed Aug 23, 2006
1 parent 842e0a7 commit fb98e13
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/gui/qgsspatialrefsys.cpp
Expand Up @@ -173,9 +173,11 @@ void QgsSpatialRefSys::validate()
return;
}
}

QSettings mySettings;
QString myDefaultProjectionOption =
mySettings.readEntry("/Projections/defaultBehaviour");

if (myDefaultProjectionOption=="prompt")
{
//@note this class is not a descendent of QWidget so we cant pass
Expand All @@ -188,6 +190,8 @@ void QgsSpatialRefSys::validate()
if(mySelector->exec())
{
createFromSrsId(mySelector->getCurrentSRSID());
delete mySelector;
return;
}
else
{
Expand All @@ -200,10 +204,12 @@ void QgsSpatialRefSys::validate()
// XXX TODO: Change project to store selected CS as 'projectSRS' not 'selectedWKT'
mProj4String = QgsProject::instance()->readEntry("SpatialRefSys","//ProjectSRSProj4String",GEOPROJ4);
}
else ///Projections/defaultBehaviour==useDefault
else ///Projections/defaultBehaviour==useGlobal
{
// XXX TODO: Change global settings to store default CS as 'defaultSRS' not 'defaultProjectionWKT'
mProj4String = mySettings.readEntry("/Projections/defaultSRS",GEOPROJ4);
int srs_id = mySettings.readNumEntry("/Projections/defaultProjectionSRSID",GEOSRS_ID);
createFromSrsId(srs_id);
return;
}

//
Expand All @@ -222,7 +228,9 @@ void QgsSpatialRefSys::validate()
//default to proj 4..if all else fails we will use that for this srs
mProj4String = GEOPROJ4;
}

createFromProj4(mProj4String);

return;
}

Expand Down Expand Up @@ -460,6 +468,7 @@ bool QgsSpatialRefSys::createFromSrsId (long theSrsId)
mGeoFlag = (geo == 0 ? false : true);
setMapUnits();
mIsValidFlag = true;

}
else
{
Expand Down
11 changes: 9 additions & 2 deletions src/raster/qgsrasterlayer.cpp
Expand Up @@ -88,7 +88,7 @@ wish to see edbug messages printed to stdout.
#include <QDomElement>
#include <QFrame>
#include <QPixmap>

#include <QSettings>
/*
*
* New includes that will convert this class to a data provider interface
Expand Down Expand Up @@ -690,8 +690,15 @@ QString QgsRasterLayer::getProjectionWKT()
{
//try to get the gcp srs from the raster layer if available
myWKTString=QString(gdalDataset->GetGCPProjection());
mySRS.createFromWkt(myWKTString);
if (!mySRS.isValid())
{
// set to default here?
QSettings settings;
int srsid = settings.readNumEntry("Projections/defaultProjectionSRSID", 4326);
mySRS.createFromId(srsid, QgsSpatialRefSys::QGIS_SRSID);
}
}


return myWKTString;
}
Expand Down

0 comments on commit fb98e13

Please sign in to comment.