Skip to content

Commit

Permalink
unset QgsMapRenderer mCachedTrForLayer on setDestinationCrs and alway…
Browse files Browse the repository at this point in the history
…s check layer->crs against mCachedTr destCRS
  • Loading branch information
blazek committed Jan 15, 2012
1 parent a6df30c commit 9a9b53b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/core/qgscoordinatereferencesystem.sip
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatereferencesystem.h
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/core/qgsmaprenderer.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -770,6 +774,7 @@ QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, Q
{
// leave extent unchanged
}
QgsDebugMsg( QString( "proj extent = " + extent.toString() ) );

return extent;
}
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 9a9b53b

Please sign in to comment.