Skip to content

Commit

Permalink
Merge pull request #42409 from rldhont/server-wms-capabilities-featur…
Browse files Browse the repository at this point in the history
…e-count

[Server] Speed up WMS GetCapabilities by removing featureCount
  • Loading branch information
elpaso committed Mar 23, 2021
2 parents e45b819 + f03b1ad commit 803848a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Expand Up @@ -1065,37 +1065,37 @@ namespace QgsWms

//Ex_GeographicBoundingBox
QgsRectangle extent = l->extent(); // layer extent by default
QgsRectangle wgs84Extent = l->wgs84Extent();
if ( l->type() == QgsMapLayerType::VectorLayer )
QgsRectangle wgs84Extent;
if ( extent.isEmpty() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
if ( vl && vl->featureCount() == 0 )
// if the extent is empty (not only Null), use the wms extent
// defined in the project...
extent = QgsServerProjectUtils::wmsExtent( *project );
if ( extent.isNull() )
{
// if there's no feature, use the wms extent defined in the
// project...
wgs84Extent = QgsRectangle();
extent = QgsServerProjectUtils::wmsExtent( *project );
if ( extent.isNull() )
// or the CRS extent otherwise
extent = l->crs().bounds();
}
else if ( l->crs() != project->crs() )
{
// If CRS is different transform it to layer's CRS
try
{
// or the CRS extent otherwise
extent = vl->crs().bounds();
QgsCoordinateTransform ct( project->crs(), l->crs(), project->transformContext() );
extent = ct.transform( extent );
}
// If CRS is different transform it to layer's CRS
else if ( vl->crs() != project->crs() )
catch ( QgsCsException &cse )
{
try
{
QgsCoordinateTransform ct( project->crs(), vl->crs(), project->transformContext() );
extent = ct.transform( extent );
}
catch ( QgsCsException &cse )
{
QgsMessageLog::logMessage( QStringLiteral( "Error transforming extent for layer %1: %2" ).arg( vl->name() ).arg( cse.what() ), QStringLiteral( "Server" ), Qgis::MessageLevel::Warning );
continue;
}
QgsMessageLog::logMessage( QStringLiteral( "Error transforming extent for layer %1: %2" ).arg( l->name() ).arg( cse.what() ), QStringLiteral( "Server" ), Qgis::MessageLevel::Warning );
continue;
}
}
}
else
{
// Get the wgs84 extent from layer
wgs84Extent = l->wgs84Extent();
}

appendLayerBoundingBoxes( doc, layerElem, extent, l->crs(), crsList, outputCrsList, project, wgs84Extent );
}
Expand Down

0 comments on commit 803848a

Please sign in to comment.