Skip to content
Permalink
Browse files

Bug fix from r6363 in 0.8.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6364 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann
homann committed Jan 1, 2007
1 parent 13003c9 commit 2339a9b462b3395a27786ff4414aa0da57f6f205
@@ -119,6 +119,7 @@ void QgsCoordinateTransform::initialise()
// Pass through with no projection since we have no idea what the layer
// coordinates are and projecting them may not be appropriate
mShortCircuit = true;
QgsDebugMsg("SourceSRS deemed invalid!");
return;
}

@@ -130,22 +131,6 @@ void QgsCoordinateTransform::initialise()
mDestSRS.createFromProj4(mSourceSRS.proj4String());
}

//XXX todo overload == operator for QgsSpatialRefSys
//at the moment srs.parameters contains the whole proj def...soon it wont...
//if (mSourceSRS->proj4String() == mDestSRS->proj4String())
if (mSourceSRS == mDestSRS)
{
// If the source and destination projection are the same, set the short
// circuit flag (no transform takes place)
mShortCircuit=true;
return;
}
else
{
// Transform must take place
mShortCircuit=false;
}

// init the projections (destination and source)
mDestinationProjection = pj_init_plus(mDestSRS.proj4String());
mSourceProjection = pj_init_plus(mSourceSRS.proj4String());
@@ -176,6 +161,23 @@ void QgsCoordinateTransform::initialise()
QgsDebugMsg("------------------------------------------------------------");
}
#endif

//XXX todo overload == operator for QgsSpatialRefSys
//at the moment srs.parameters contains the whole proj def...soon it wont...
//if (mSourceSRS->proj4String() == mDestSRS->proj4String())
if (mSourceSRS == mDestSRS)
{
// If the source and destination projection are the same, set the short
// circuit flag (no transform takes place)
mShortCircuit=true;
QgsDebugMsg("Source/Dest SRS equal, shortcircuit is set.");
}
else
{
// Transform must take place
mShortCircuit=false;
}

}

//
@@ -260,6 +260,7 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
QDomNode srsNode = layer_node.namedItem("coordinatetransform");
if( ! srsNode.isNull() )
{
qDebug("Reading coordinatetransform from project file");
mCoordinateTransform=new QgsCoordinateTransform();
mCoordinateTransform->readXML(srsNode);
}
@@ -268,7 +269,7 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
QDomNode transparencyNode = layer_node.namedItem("transparencyLevelInt");
if ( ! transparencyNode.isNull() )
{
// set transparency level only if it's in project
// set transparency level only if it's in project
// (otherwise it sets the layer transparent)
QDomElement myElement = transparencyNode.toElement();
setTransparency(myElement.text().toInt());
@@ -25,6 +25,7 @@
#include "qgsmaplayerregistry.h"
#include "qgsproject.h"
#include "qgsrenderer.h"
#include "qgslogger.h"

//qt includes
#include <QColorDialog>
@@ -61,6 +62,7 @@
}
// set the default wkt to WGS 84
long mySRSID = QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectSRSID",GEOSRS_ID);
QgsDebugMsg("Read project SRSID: " + QString::number(mySRSID));
projectionSelector->setSelectedSRSID(mySRSID);


@@ -3506,7 +3506,9 @@ void QgsVectorLayer::setCoordinateSystem()
// project srs

QgsDebugMsg("Layer registry has " + QString::number(QgsMapLayerRegistry::instance()->count()) + " layers ");
if (QgsMapLayerRegistry::instance()->count() ==0)
// No reason to set project SRS
// if (QgsMapLayerRegistry::instance()->count() ==0)
if (NULL)
{
mCoordinateTransform->destSRS().createFromProj4(
mCoordinateTransform->sourceSRS().proj4String());
@@ -491,7 +491,9 @@ void QgsRasterLayer::setupDestSrs()
{
QgsDebugMsg("Layer registry has " + QString::number(QgsMapLayerRegistry::instance()->count()) + "layers");

if (QgsMapLayerRegistry::instance()->count() ==0)
// No reason to set project SRS
// if (QgsMapLayerRegistry::instance()->count() ==0)
if (NULL)
{
mCoordinateTransform->destSRS().createFromProj4(
mCoordinateTransform->sourceSRS().proj4String());
@@ -551,22 +553,32 @@ QgsRasterLayer::readFile( QString const & fileName )
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");

// Get the layer's projection info and set up the
// QgsCoordinateTransform for this layer
// NOTE: we must do this before getMetadata is called
mCoordinateTransform = new QgsCoordinateTransform();
QString mySourceWKT = getProjectionWKT();

QgsDebugMsg("--------------------------------------------------------------------------------------");
QgsDebugMsg("QgsRasterLayer::readFile --- using wkt\n" + mySourceWKT);
QgsDebugMsg("--------------------------------------------------------------------------------------");

mCoordinateTransform->sourceSRS().createFromWkt(mySourceWKT);
//get the project projection, defaulting to this layer's projection
//if none exists....
if (!mCoordinateTransform->sourceSRS().isValid())
if (mCoordinateTransform && mCoordinateTransform->sourceSRS().isValid())
{
// Layer source SRS is already set, probably by reading XML from project file
// This setting should override any GDAL info.
QgsDebugMsg("Source SRS is alerady set. Ignoring GDAL projection info");
}
else
{
mCoordinateTransform->sourceSRS().validate();
// Get the layer's projection info and set up the
// QgsCoordinateTransform for this layer
// NOTE: we must do this before getMetadata is called
mCoordinateTransform = new QgsCoordinateTransform();
QString mySourceWKT = getProjectionWKT();

QgsDebugMsg("--------------------------------------------------------------------------------------");
QgsDebugMsg("QgsRasterLayer::readFile --- using wkt\n" + mySourceWKT);
QgsDebugMsg("--------------------------------------------------------------------------------------");

mCoordinateTransform->sourceSRS().createFromWkt(mySourceWKT);
//get the project projection, defaulting to this layer's projection
//if none exists....
if (!mCoordinateTransform->sourceSRS().isValid())
{
mCoordinateTransform->sourceSRS().validate();
}
}

setupDestSrs();
@@ -4527,6 +4539,8 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
QgsDebugMsg("ReadXml: red band name " + redBandNameQString);
QgsDebugMsg("ReadXml: green band name " + greenBandNameQString);
QgsDebugMsg("Drawing style " + getDrawingStyleAsQString());
QgsDebugMsg("Source SRS: " + mCoordinateTransform->sourceSRS().description());
QgsDebugMsg("Dest SRS: " + mCoordinateTransform->destSRS().description());

return true;

0 comments on commit 2339a9b

Please sign in to comment.
You can’t perform that action at this time.