Skip to content
Permalink
Browse files

Merge pull request #42084 from mhugent/server_fix_external_wms_opacities

Server: Opacity should also be considered for external layers
  • Loading branch information
mhugent committed Mar 15, 2021
2 parents 7550fbe + 3f8c8e2 commit f80a7541ed9d5a277505e0702cbccf9f5f584902
@@ -1576,6 +1576,9 @@ namespace QgsWms
QgsWmsParametersLayer param;
param.mNickname = layer;

if ( i < opacities.count() )
param.mOpacity = opacities[i];

if ( isExternalLayer( layer ) )
{
const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
@@ -1587,9 +1590,6 @@ namespace QgsWms
if ( i < styles.count() )
param.mStyle = styles[i];

if ( i < opacities.count() )
param.mOpacity = opacities[i];

if ( filters.contains( layer ) )
{
auto it = filters.find( layer );
@@ -3287,6 +3287,10 @@ namespace QgsWms

if ( mContext.isExternalLayer( param.mNickname ) )
{
if ( mContext.testFlag( QgsWmsRenderContext::UseOpacity ) )
{
setLayerOpacity( layer, param.mOpacity );
}
continue;
}

@@ -53,6 +53,8 @@ void TestQgsServerWmsParameters::external_layers()
query.addQueryItem( "external_layer_1:layers", "layer_1_name" );
query.addQueryItem( "external_layer_2:url", "http://url_2" );
query.addQueryItem( "external_layer_2:layers", "layer_2_name" );
query.addQueryItem( "external_layer_2:opacities", "100" );
query.addQueryItem( "OPACITIES", "255,200,125" );

QgsWms::QgsWmsParameters parameters( query );

@@ -68,7 +70,12 @@ void TestQgsServerWmsParameters::external_layers()

layer_params = layers_params[2];
QCOMPARE( layer_params.mNickname, QString( "external_layer_2" ) );
QCOMPARE( layer_params.mExternalUri, QString( "layers=layer_2_name&url=http://url_2" ) );
QCOMPARE( layer_params.mExternalUri, QString( "layers=layer_2_name&opacities=100&url=http://url_2" ) );

//test if opacities are also applied to external layers
QCOMPARE( layers_params[0].mOpacity, 255 );
QCOMPARE( layers_params[1].mOpacity, 200 );
QCOMPARE( layers_params[2].mOpacity, 125 );
}

void TestQgsServerWmsParameters::percent_encoding()

0 comments on commit f80a754

Please sign in to comment.