Skip to content

Commit

Permalink
Do not add STYLES to WMS collection data items
Browse files Browse the repository at this point in the history
Fixes #45192
  • Loading branch information
elpaso authored and nyalldawson committed Sep 22, 2021
1 parent ec57fb2 commit 7ec01c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/providers/wms/qgswmsdataitems.cpp
Expand Up @@ -12,6 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgswmsdataitems.h"

#include "qgslogger.h"
Expand All @@ -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" ) )
Expand Down Expand Up @@ -271,15 +273,15 @@ QgsWMSItemBase::QgsWMSItemBase( const QgsWmsCapabilitiesProperty &capabilitiesPr
{
}

QString QgsWMSItemBase::createUri()
QString QgsWMSItemBase::createUri( bool withStyle )
{
if ( mLayerProperty.name.isEmpty() )
return QString(); // layer collection

// 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 ) )
Expand Down Expand Up @@ -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 ) )
Expand Down
4 changes: 3 additions & 1 deletion src/providers/wms/qgswmsdataitems.h
Expand Up @@ -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;
Expand Down

0 comments on commit 7ec01c0

Please sign in to comment.