Skip to content
Permalink
Browse files

Merge pull request #37425 from rldhont/qgis-bot-backport-35277-35937-…

…to-release-3_10

[Backport release-3_10] Fix regression in QGIS Server WMS GetPrint request with a group layer
  • Loading branch information
rldhont committed Jun 30, 2020
2 parents 62563f0 + 8d92dfa commit b1e3845ba633a65345bd0ab55b7c64c320f16393
@@ -287,6 +287,11 @@ bool QgsWmsRenderContext::isValidLayer( const QString &nickname ) const
return layer( nickname ) != nullptr;
}

QList<QgsMapLayer *> QgsWmsRenderContext::layersFromGroup( const QString &nickname ) const
{
return mLayerGroups.value( nickname );
}

bool QgsWmsRenderContext::isValidGroup( const QString &name ) const
{
return mLayerGroups.contains( name );
@@ -178,6 +178,12 @@ namespace QgsWms
*/
bool isValidLayer( const QString &nickname ) const;

/**
* Returns the group's layers list corresponding to the nickname, or
* an empty list if not found.
*/
QList<QgsMapLayer *> layersFromGroup( const QString &nickname ) const;

/**
* Returns true if \a name is a group.
*/
@@ -589,15 +589,39 @@ namespace QgsWms
QList<QgsMapLayer *> layerSet;
for ( auto layer : cMapParams.mLayers )
{
QgsMapLayer *mlayer = mContext.layer( layer.mNickname );

if ( ! mlayer )
if ( mContext.isValidGroup( layer.mNickname ) )
{
continue;
QList<QgsMapLayer *> layersFromGroup;

const QList<QgsMapLayer *> cLayersFromGroup = mContext.layersFromGroup( layer.mNickname );
for ( QgsMapLayer *layerFromGroup : cLayersFromGroup )
{

if ( ! layerFromGroup )
{
continue;
}

layersFromGroup.push_front( layerFromGroup );
}

if ( !layersFromGroup.isEmpty() )
{
layerSet.append( layersFromGroup );
}
}
else
{
QgsMapLayer *mlayer = mContext.layer( layer.mNickname );

setLayerStyle( mlayer, layer.mStyle );
layerSet << mlayer;
if ( ! mlayer )
{
continue;
}

setLayerStyle( mlayer, layer.mStyle );
layerSet << mlayer;
}
}

layerSet << externalLayers( cMapParams.mExternalLayers );
@@ -312,6 +312,9 @@ IF (WITH_SERVER)
ADD_PYTHON_TEST(PyQgsServerWMSGetFeatureInfo test_qgsserver_wms_getfeatureinfo.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetLegendGraphic test_qgsserver_wms_getlegendgraphic.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrint test_qgsserver_wms_getprint.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrintExtra test_qgsserver_wms_getprint_extra.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrintOutputs test_qgsserver_wms_getprint_outputs.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrintAtlas test_qgsserver_wms_getprint_atlas.py)
ADD_PYTHON_TEST(PyQgsServerWMSDimension test_qgsserver_wms_dimension.py)
ADD_PYTHON_TEST(PyQgsServerSettings test_qgsserver_settings.py)
ADD_PYTHON_TEST(PyQgsServerProjectUtils test_qgsserver_projectutils.py)

0 comments on commit b1e3845

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