@@ -67,7 +67,8 @@ namespace QgsWms
67
67
68
68
void appendLayerBoundingBoxes ( QDomDocument &doc, QDomElement &layerElem, const QgsRectangle &lExtent,
69
69
const QgsCoordinateReferenceSystem &layerCRS, const QStringList &crsList,
70
- const QStringList &constrainedCrsList, const QgsProject *project );
70
+ const QStringList &constrainedCrsList, const QgsProject *project,
71
+ const QgsRectangle &geoExtent = QgsRectangle() );
71
72
72
73
void appendCrsElementToLayer ( QDomDocument &doc, QDomElement &layerElement, const QDomElement &precedingElement,
73
74
const QString &crsText );
@@ -1094,7 +1095,7 @@ namespace QgsWms
1094
1095
}
1095
1096
}
1096
1097
1097
- appendLayerBoundingBoxes ( doc, layerElem, extent, l->crs (), crsList, outputCrsList, project );
1098
+ appendLayerBoundingBoxes ( doc, layerElem, extent, l->crs (), crsList, outputCrsList, project, l-> geographicExtent () );
1098
1099
}
1099
1100
1100
1101
// add details about supported styles of the layer
@@ -1416,7 +1417,8 @@ namespace QgsWms
1416
1417
1417
1418
void appendLayerBoundingBoxes ( QDomDocument &doc, QDomElement &layerElem, const QgsRectangle &lExtent,
1418
1419
const QgsCoordinateReferenceSystem &layerCRS, const QStringList &crsList,
1419
- const QStringList &constrainedCrsList, const QgsProject *project )
1420
+ const QStringList &constrainedCrsList, const QgsProject *project,
1421
+ const QgsRectangle &lGeoExtent )
1420
1422
{
1421
1423
if ( layerElem.isNull () )
1422
1424
{
@@ -1430,29 +1432,31 @@ namespace QgsWms
1430
1432
layerExtent.grow ( 0.000001 );
1431
1433
}
1432
1434
1433
- QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs ( geoEpsgCrsAuthId () );
1434
- int wgs84precision = 6 ;
1435
-
1436
- QString version = doc.documentElement ().attribute ( QStringLiteral ( " version" ) );
1437
-
1438
- // Ex_GeographicBoundingBox
1439
- QDomElement ExGeoBBoxElement;
1440
- // transform the layers native CRS into WGS84
1441
- QgsRectangle wgs84BoundingRect;
1442
- if ( !layerExtent.isNull () )
1435
+ QgsRectangle wgs84BoundingRect = lGeoExtent;
1436
+ if ( wgs84BoundingRect.isNull () )
1443
1437
{
1444
- QgsCoordinateTransform exGeoTransform ( layerCRS, wgs84, project );
1445
- try
1446
- {
1447
- wgs84BoundingRect = exGeoTransform.transformBoundingBox ( layerExtent );
1448
- }
1449
- catch ( const QgsCsException &cse )
1438
+ QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs ( geoEpsgCrsAuthId () );
1439
+
1440
+ // transform the layers native CRS into WGS84
1441
+ if ( !layerExtent.isNull () )
1450
1442
{
1451
- QgsMessageLog::logMessage ( QStringLiteral ( " Error transforming extent: %1" ).arg ( cse.what () ), QStringLiteral ( " Server" ), Qgis::MessageLevel::Warning );
1452
- wgs84BoundingRect = QgsRectangle ();
1443
+ QgsCoordinateTransform exGeoTransform ( layerCRS, wgs84, project );
1444
+ try
1445
+ {
1446
+ wgs84BoundingRect = exGeoTransform.transformBoundingBox ( layerExtent );
1447
+ }
1448
+ catch ( const QgsCsException &cse )
1449
+ {
1450
+ QgsMessageLog::logMessage ( QStringLiteral ( " Error transforming extent: %1" ).arg ( cse.what () ), QStringLiteral ( " Server" ), Qgis::MessageLevel::Warning );
1451
+ wgs84BoundingRect = QgsRectangle ();
1452
+ }
1453
1453
}
1454
1454
}
1455
1455
1456
+ // Ex_GeographicBoundingBox
1457
+ int wgs84precision = 6 ;
1458
+ QDomElement ExGeoBBoxElement;
1459
+ QString version = doc.documentElement ().attribute ( QStringLiteral ( " version" ) );
1456
1460
if ( version == QLatin1String ( " 1.1.1" ) ) // WMS Version 1.1.1
1457
1461
{
1458
1462
ExGeoBBoxElement = doc.createElement ( QStringLiteral ( " LatLonBoundingBox" ) );
0 commit comments