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@12318 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Dec 3, 2009
1 parent 8c4573c commit 0e76f1dd9cb7d4ad9da2033dd894c7bd9549e5da
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 0e76f1d

Please sign in to comment.