From e4f5b93abb787e57c25e0f4320cc8bc425598fe7 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Wed, 22 Sep 2021 19:10:57 +0200 Subject: [PATCH] Do not add STYLES to WMS collection data items Fixes #45192 --- src/providers/wms/qgswmsdataitems.cpp | 9 ++++++--- src/providers/wms/qgswmsdataitems.h | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/providers/wms/qgswmsdataitems.cpp b/src/providers/wms/qgswmsdataitems.cpp index 7f9c0e88a688..644a8a07a0fa 100644 --- a/src/providers/wms/qgswmsdataitems.cpp +++ b/src/providers/wms/qgswmsdataitems.cpp @@ -12,6 +12,7 @@ * (at your option) any later version. * * * ***************************************************************************/ + #include "qgswmsdataitems.h" #include "qgslogger.h" @@ -26,6 +27,7 @@ #include "qgsgeonoderequest.h" #include "qgssettings.h" + // --------------------------------------------------------------------------- QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem *parent, QString name, QString path, QString uri ) : QgsDataCollectionItem( parent, name, path, QStringLiteral( "WMS" ) ) @@ -271,7 +273,7 @@ QgsWMSItemBase::QgsWMSItemBase( const QgsWmsCapabilitiesProperty &capabilitiesPr { } -QString QgsWMSItemBase::createUri() +QString QgsWMSItemBase::createUri( bool withStyle ) { if ( mLayerProperty.name.isEmpty() ) return QString(); // layer collection @@ -279,7 +281,7 @@ QString QgsWMSItemBase::createUri() // Number of styles must match number of layers mDataSourceUri.setParam( QStringLiteral( "layers" ), mLayerProperty.name ); QString style = !mLayerProperty.style.isEmpty() ? mLayerProperty.style.at( 0 ).name : QString(); - mDataSourceUri.setParam( QStringLiteral( "styles" ), style ); + mDataSourceUri.setParam( QStringLiteral( "styles" ), withStyle ? style : QString() ); // Check for layer dimensions for ( const QgsWmsDimensionProperty &dimension : std::as_const( mLayerProperty.dimensions ) ) @@ -346,7 +348,8 @@ QgsWMSLayerCollectionItem::QgsWMSLayerCollectionItem( QgsDataItem *parent, QStri , QgsWMSItemBase( capabilitiesProperty, dataSourceUri, layerProperty ) { mIconName = QStringLiteral( "mIconWms.svg" ); - mUri = createUri(); + // For collection items we want the default style (empty) so let's strip it + mUri = createUri( /* withStyle */ false ); // Populate everything, it costs nothing, all info about layers is collected for ( const QgsWmsLayerProperty &layerProperty : std::as_const( mLayerProperty.layer ) ) diff --git a/src/providers/wms/qgswmsdataitems.h b/src/providers/wms/qgswmsdataitems.h index 77ff0b3e168d..36869ba5fdae 100644 --- a/src/providers/wms/qgswmsdataitems.h +++ b/src/providers/wms/qgswmsdataitems.h @@ -69,8 +69,10 @@ class QgsWMSItemBase * - "allowTemporalUpdates": whether to allow updates on temporal parameters on this uri * - "temporalSource": the source of the layer's temporal range, can be either "provider" or "project" * - "enableTime": if the provider using time part in the temporal range datetime instances + * + * \param withStyle default TRUE, also adds the style to the URL, it should be empty for collection items */ - QString createUri(); + QString createUri( bool withStyle = true ); //! Stores GetCapabilities response QgsWmsCapabilitiesProperty mCapabilitiesProperty;