Skip to content
Permalink
Browse files

unset QgsMapRenderer mCachedTrForLayer on setDestinationCrs and alway…

…s check layer->crs against mCachedTr destCRS
  • Loading branch information
blazek committed Jan 15, 2012
1 parent a6df30c commit 9a9b53bb944f3f98dbf080fc8fcdc00ce5fd7e02
@@ -159,11 +159,11 @@ class QgsCoordinateReferenceSystem
/*! Overloaded == operator used to compare to CRS's.
* Internally it will delegate to the equals method described below
*/
bool operator==(const QgsCoordinateReferenceSystem &theSrs);
bool operator==(const QgsCoordinateReferenceSystem &theSrs) const;
/*! Overloaded != operator used to compare to CRS's.
* Returns opposite bool value to operator ==
*/
bool operator!=(const QgsCoordinateReferenceSystem &theSrs);
bool operator!=(const QgsCoordinateReferenceSystem &theSrs) const;
/*! Overloaded == operator used to compare to CRS's.
* Internally it will use OGR isSameCRS() or isSameGeoCRS() methods as appropriate.
* Additionally logic may also be applied if the result from the OGR methods
@@ -979,12 +979,12 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
return 0;
}

bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs )
bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs ) const
{
return mIsValidFlag && theSrs.mIsValidFlag && toWkt() == theSrs.toWkt();
}

bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs )
bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs ) const
{
return !( *this == theSrs );
}
@@ -201,11 +201,11 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
/*! Overloaded == operator used to compare to CRS's.
* Internally it will delegate to the equals method described below
*/
bool operator==( const QgsCoordinateReferenceSystem &theSrs );
bool operator==( const QgsCoordinateReferenceSystem &theSrs ) const;
/*! Overloaded != operator used to compare to CRS's.
* Returns opposite bool value to operator ==
*/
bool operator!=( const QgsCoordinateReferenceSystem &theSrs );
bool operator!=( const QgsCoordinateReferenceSystem &theSrs ) const;
/*! Overloaded == operator used to compare to CRS's.
* Internally it will use OGR isSameCRS() or isSameGeoCRS() methods as appropriate.
* Additionally logic may also be applied if the result from the OGR methods
@@ -680,6 +680,7 @@ void QgsMapRenderer::setDestinationCrs( const QgsCoordinateReferenceSystem& crs
QgsDebugMsg( "* DestCRS.srsid() = " + QString::number( crs.srsid() ) );
if ( *mDestCRS != crs )
{
mCachedTrForLayer = 0;
QgsDebugMsg( "Setting DistArea CRS to " + QString::number( crs.srsid() ) );
mDistArea->setSourceCrs( crs.srsid() );
*mDestCRS = crs;
@@ -754,6 +755,9 @@ bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRectangle& extent

QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent )
{
QgsDebugMsg( QString( "sourceCrs = " + tr( theLayer )->sourceCrs().authid() ) );
QgsDebugMsg( QString( "destCRS = " + tr( theLayer )->destCRS().authid() ) );
QgsDebugMsg( QString( "extent = " + extent.toString() ) );
if ( hasCrsTransformEnabled() )
{
try
@@ -770,6 +774,7 @@ QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, Q
{
// leave extent unchanged
}
QgsDebugMsg( QString( "proj extent = " + extent.toString() ) );

return extent;
}
@@ -1102,7 +1107,8 @@ void QgsMapRenderer::setLabelingEngine( QgsLabelingEngineInterface* iface )

QgsCoordinateTransform *QgsMapRenderer::tr( QgsMapLayer *layer )
{
if ( mCachedTrForLayer != layer )
// mCachedTrForLayer is unset by setDestinationCrs(), but layer->crs may also be changed after CRS was cached -> check it - the question is, how efficient now the caching is, because crs == operator is not cheap
if ( mCachedTrForLayer != layer || layer->crs() != mCachedTr->sourceCrs() )
{
delete mCachedTr;
mCachedTr = new QgsCoordinateTransform( layer->crs(), *mDestCRS );

0 comments on commit 9a9b53b

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