Skip to content

Commit 6eeaa51

Browse files
author
mhugent
committed
For the calculation of the extent of WMS layers: ignore layers where the bounding boxes cannot be transformed into the requested coordinate system
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5537 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2348cb3 commit 6eeaa51

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/providers/wms/qgswmsprovider.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,7 @@ bool QgsWmsProvider::calculateExtent()
19161916
mCoordinateTransform = new QgsCoordinateTransform(qgisSrsSource, qgisSrsDest);
19171917
}
19181918

1919+
bool firstLayer = true; //flag to know if a layer is the first to be successfully transformed
19191920
for ( QStringList::Iterator it = activeSubLayers.begin();
19201921
it != activeSubLayers.end();
19211922
++it )
@@ -1925,21 +1926,26 @@ bool QgsWmsProvider::calculateExtent()
19251926
QgsRect extent = extentForLayer.find( *it )->second;
19261927

19271928
// Convert to the user's CRS as required
1928-
extent =
1929-
mCoordinateTransform->transformBoundingBox(
1930-
extent,
1931-
QgsCoordinateTransform::FORWARD
1932-
);
1929+
try
1930+
{
1931+
extent = mCoordinateTransform->transformBoundingBox(extent, QgsCoordinateTransform::FORWARD);
1932+
}
1933+
catch(QgsCsException &cse)
1934+
{
1935+
continue; //ignore extents of layers which cannot be transformed info the required CRS
1936+
}
19331937

19341938
// add to the combined extent of all the active sublayers
1935-
if ( it == activeSubLayers.begin() )
1939+
if (firstLayer)
19361940
{
19371941
layerExtent = extent;
19381942
}
19391943
else
19401944
{
19411945
layerExtent.combineExtentWith( &extent );
19421946
}
1947+
1948+
firstLayer = false;
19431949

19441950
#ifdef QGISDEBUG
19451951
std::cout << "QgsWmsProvider::calculateExtent: combined extent is '" <<

0 commit comments

Comments
 (0)