Skip to content
Permalink
Browse files

Allow the usage of opacity parameter in a WMS provider URL

  • Loading branch information
mhugent committed Nov 17, 2020
1 parent 9708edb commit d2e953e0959a572012dc5bf87a694c503ebc7741
@@ -138,6 +138,27 @@ 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();
QStringList opacities = uri.params( QStringLiteral( "opacities" ) );
QStringList::const_iterator oIt = opacities.constBegin();
for ( ; oIt != opacities.constEnd(); ++oIt )
{
bool ok = false;
oIt->toInt( &ok );
if ( ok )
{
mOpacities.append( *oIt );
}
else
{
mOpacities.append( QStringLiteral( "255" ) );
}
}
}

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

@@ -933,6 +933,8 @@ class QgsWmsSettings
QStringList mActiveSubLayers;
QStringList 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 d2e953e

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