Skip to content
Permalink
Browse files

Fix zoom to layer if otf-reprojection is enabled (ticket #2148)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12318 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Dec 3, 2009
1 parent 8f00ae3 commit 51de01b53e0e80c9ff1590ee24ad3a1bc5cb260c
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/app/legend/qgslegend.cpp
@@ -1581,6 +1581,11 @@ void QgsLegend::makeToTopLevelItem()

void QgsLegend::legendLayerZoom()
{
if(!mMapCanvas)
{
return;
}

//find current Layer
QgsLegendLayer* currentLayer = dynamic_cast<QgsLegendLayer *>( currentItem() );
if ( !currentLayer )
@@ -1589,6 +1594,16 @@ void QgsLegend::legendLayerZoom()
QgsMapLayer* theLayer = currentLayer->layer();
QgsRectangle extent = theLayer->extent();

//transform extent if otf-projection is on
if(mMapCanvas->hasCrsTransformEnabled())
{
QgsMapRenderer* renderer = mMapCanvas->mapRenderer();
if(renderer)
{
extent = renderer->layerExtentToOutputExtent(theLayer, extent);
}
}

// Increase bounding box with 5%, so that layer is a bit inside the borders
extent.scale( 1.05 );

0 comments on commit 51de01b

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