Skip to content
Permalink
Browse files

Merge pull request #40121 from mhugent/external_wms_opacities

Allow the usage of opacity parameter in a WMS provider URL
  • Loading branch information
mhugent committed Nov 18, 2020
2 parents 869e90c + 3145449 commit 234bd31241255f4bce3cfb5763a100868855a764
@@ -138,6 +138,26 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
mActiveSubStyles = uri.params( QStringLiteral( "styles" ) );
QgsDebugMsgLevel( "Entering: layers:" + mActiveSubLayers.join( ", " ) + ", styles:" + mActiveSubStyles.join( ", " ), 2 );

//opacities
if ( uri.hasParam( QStringLiteral( "opacities" ) ) )
{
mOpacities.clear();
const QStringList opacities = uri.params( QStringLiteral( "opacities" ) );
for ( const QString &opacity : opacities )
{
bool ok = false;
opacity.toInt( &ok );
if ( ok )
{
mOpacities.append( opacity );
}
else
{
mOpacities.append( QStringLiteral( "255" ) );
}
}
}

mImageMimeType = uri.param( QStringLiteral( "format" ) );
QgsDebugMsgLevel( "Setting image encoding to " + mImageMimeType + '.', 2 );

@@ -933,6 +933,9 @@ class QgsWmsSettings
QStringList mActiveSubLayers;
QStringList mActiveSubStyles;

//! Opacities for wms layers. Same ordering as mActiveSubLayers/mActiveSubStyles
QStringList mOpacities;

/**
* Visibility status of the given active sublayer
*/
@@ -1068,6 +1068,11 @@ QUrl QgsWmsProvider::createRequestUrlWMS( const QgsRectangle &viewExtent, int pi
setQueryItem( query, QStringLiteral( "HEIGHT" ), QString::number( pixelHeight ) );
setQueryItem( query, QStringLiteral( "LAYERS" ), layers );
setQueryItem( query, QStringLiteral( "STYLES" ), styles );
QStringList opacityList = mSettings.mOpacities;
if ( !opacityList.isEmpty() )
{
setQueryItem( query, QStringLiteral( "OPACITIES" ), mSettings.mOpacities.join( ',' ) );
}

// For WMS-T layers
if ( temporalCapabilities() &&
@@ -1891,7 +1891,7 @@ namespace QgsWms
for ( ; paramIt != paramMap.constEnd(); ++paramIt )
{
QString paramName = paramIt.key().toLower();
if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) )
if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
{
const QStringList values = paramIt.value().split( ',' );
for ( const QString &value : values )

0 comments on commit 234bd31

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