Skip to content
Permalink
Browse files

Fix for ticket #474. The behaviour when different layers are being re…

…projected

into coordinate systems that are 'not right' will still be a bit confusing to
the novice user, but qgis won't crash when doing so now.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6345 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m
g_j_m committed Dec 29, 2006
1 parent eb5389c commit 6e90804d8cfc3ab46ea71e341559c653217c1890
Showing with 15 additions and 9 deletions.
  1. +15 −9 src/legend/qgslegend.cpp
@@ -1689,7 +1689,7 @@ void QgsLegend::zoomToLayerExtent()

QgsRect transformedExtent;
QgsRect layerExtent;
QgsRect r2;
QgsCoordinateTransform *ct;
QgsMapLayer* theLayer;
bool first(true);

@@ -1700,16 +1700,22 @@ void QgsLegend::zoomToLayerExtent()
{
layerExtent = theLayer->extent();

if (theLayer->projectionsEnabled())
if (theLayer->projectionsEnabled()
&& (ct = theLayer->coordinateTransform()))
{
try
{
layerExtent = ct->transformBoundingBox(layerExtent, QgsCoordinateTransform::FORWARD);
}
catch (QgsCsException &cse)
{
// Catch any exceptions, and by default the rest of the code
// just gets the unprojected extent instead.
}

// std::cerr<<__FILE__<<__LINE__<<' '
// << layerExtent.stringRep().toLocal8Bit().data() << '\n';

bool split = theLayer->projectExtent(layerExtent, r2);

// std::cerr<<__FILE__<<__LINE__<<' '
// << layerExtent.stringRep().toLocal8Bit().data() << '\n';
// If the extent is odd, default to the unprojected extent.
if (!layerExtent.isFinite())
layerExtent = theLayer->extent();
}

if (first)

0 comments on commit 6e90804

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