Skip to content

Commit 23f0177

Browse files
author
homann
committed
Bug fix from r6363 in 0.8.
git-svn-id: http://svn.osgeo.org/qgis/trunk@6364 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9321391 commit 23f0177

File tree

5 files changed

+54
-33
lines changed

5 files changed

+54
-33
lines changed

src/gui/qgscoordinatetransform.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void QgsCoordinateTransform::initialise()
119119
// Pass through with no projection since we have no idea what the layer
120120
// coordinates are and projecting them may not be appropriate
121121
mShortCircuit = true;
122+
QgsDebugMsg("SourceSRS deemed invalid!");
122123
return;
123124
}
124125

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

133-
//XXX todo overload == operator for QgsSpatialRefSys
134-
//at the moment srs.parameters contains the whole proj def...soon it wont...
135-
//if (mSourceSRS->proj4String() == mDestSRS->proj4String())
136-
if (mSourceSRS == mDestSRS)
137-
{
138-
// If the source and destination projection are the same, set the short
139-
// circuit flag (no transform takes place)
140-
mShortCircuit=true;
141-
return;
142-
}
143-
else
144-
{
145-
// Transform must take place
146-
mShortCircuit=false;
147-
}
148-
149134
// init the projections (destination and source)
150135
mDestinationProjection = pj_init_plus(mDestSRS.proj4String());
151136
mSourceProjection = pj_init_plus(mSourceSRS.proj4String());
@@ -176,6 +161,23 @@ void QgsCoordinateTransform::initialise()
176161
QgsDebugMsg("------------------------------------------------------------");
177162
}
178163
#endif
164+
165+
//XXX todo overload == operator for QgsSpatialRefSys
166+
//at the moment srs.parameters contains the whole proj def...soon it wont...
167+
//if (mSourceSRS->proj4String() == mDestSRS->proj4String())
168+
if (mSourceSRS == mDestSRS)
169+
{
170+
// If the source and destination projection are the same, set the short
171+
// circuit flag (no transform takes place)
172+
mShortCircuit=true;
173+
QgsDebugMsg("Source/Dest SRS equal, shortcircuit is set.");
174+
}
175+
else
176+
{
177+
// Transform must take place
178+
mShortCircuit=false;
179+
}
180+
179181
}
180182

181183
//

src/gui/qgsmaplayer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
260260
QDomNode srsNode = layer_node.namedItem("coordinatetransform");
261261
if( ! srsNode.isNull() )
262262
{
263+
qDebug("Reading coordinatetransform from project file");
263264
mCoordinateTransform=new QgsCoordinateTransform();
264265
mCoordinateTransform->readXML(srsNode);
265266
}
@@ -268,7 +269,7 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
268269
QDomNode transparencyNode = layer_node.namedItem("transparencyLevelInt");
269270
if ( ! transparencyNode.isNull() )
270271
{
271-
// set transparency level only if it's in project
272+
// set transparency level only if it's in project
272273
// (otherwise it sets the layer transparent)
273274
QDomElement myElement = transparencyNode.toElement();
274275
setTransparency(myElement.text().toInt());

src/gui/qgsprojectproperties.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qgsmaplayerregistry.h"
2626
#include "qgsproject.h"
2727
#include "qgsrenderer.h"
28+
#include "qgslogger.h"
2829

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

6668

src/gui/qgsvectorlayer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3506,7 +3506,9 @@ void QgsVectorLayer::setCoordinateSystem()
35063506
// project srs
35073507

35083508
QgsDebugMsg("Layer registry has " + QString::number(QgsMapLayerRegistry::instance()->count()) + " layers ");
3509-
if (QgsMapLayerRegistry::instance()->count() ==0)
3509+
// No reason to set project SRS
3510+
// if (QgsMapLayerRegistry::instance()->count() ==0)
3511+
if (NULL)
35103512
{
35113513
mCoordinateTransform->destSRS().createFromProj4(
35123514
mCoordinateTransform->sourceSRS().proj4String());

src/raster/qgsrasterlayer.cpp

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ void QgsRasterLayer::setupDestSrs()
491491
{
492492
QgsDebugMsg("Layer registry has " + QString::number(QgsMapLayerRegistry::instance()->count()) + "layers");
493493

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

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

560-
QgsDebugMsg("--------------------------------------------------------------------------------------");
561-
QgsDebugMsg("QgsRasterLayer::readFile --- using wkt\n" + mySourceWKT);
562-
QgsDebugMsg("--------------------------------------------------------------------------------------");
563-
564-
mCoordinateTransform->sourceSRS().createFromWkt(mySourceWKT);
565-
//get the project projection, defaulting to this layer's projection
566-
//if none exists....
567-
if (!mCoordinateTransform->sourceSRS().isValid())
557+
if (mCoordinateTransform && mCoordinateTransform->sourceSRS().isValid())
558+
{
559+
// Layer source SRS is already set, probably by reading XML from project file
560+
// This setting should override any GDAL info.
561+
QgsDebugMsg("Source SRS is alerady set. Ignoring GDAL projection info");
562+
}
563+
else
568564
{
569-
mCoordinateTransform->sourceSRS().validate();
565+
// Get the layer's projection info and set up the
566+
// QgsCoordinateTransform for this layer
567+
// NOTE: we must do this before getMetadata is called
568+
mCoordinateTransform = new QgsCoordinateTransform();
569+
QString mySourceWKT = getProjectionWKT();
570+
571+
QgsDebugMsg("--------------------------------------------------------------------------------------");
572+
QgsDebugMsg("QgsRasterLayer::readFile --- using wkt\n" + mySourceWKT);
573+
QgsDebugMsg("--------------------------------------------------------------------------------------");
574+
575+
mCoordinateTransform->sourceSRS().createFromWkt(mySourceWKT);
576+
//get the project projection, defaulting to this layer's projection
577+
//if none exists....
578+
if (!mCoordinateTransform->sourceSRS().isValid())
579+
{
580+
mCoordinateTransform->sourceSRS().validate();
581+
}
570582
}
571583

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

45314545
return true;
45324546

0 commit comments

Comments
 (0)