Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add STYLES to WMS collection data items #45209

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/providers/wms/qgswmsdataitems.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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