Skip to content

Commit

Permalink
Fix zoom to layer if otf-reprojection is enabled (ticket #2148)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12318 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Dec 3, 2009
1 parent 8c4573c commit 0e76f1d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,11 @@ void QgsLegend::makeToTopLevelItem()

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

//find current Layer
QgsLegendLayer* currentLayer = dynamic_cast<QgsLegendLayer *>( currentItem() );
if ( !currentLayer )
Expand All @@ -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 );

Expand Down

0 comments on commit 0e76f1d

Please sign in to comment.