Skip to content
Permalink
Browse files

[server] do not drop layers with duplicate names

Fix #33928
  • Loading branch information
m-kuhn committed Jan 20, 2020
1 parent c4a2bb0 commit b3be308f1c8a4254cef6e850d10056e845db47eb
Showing with 22 additions and 18 deletions.
  1. +21 −17 src/server/services/wms/qgswmsrendercontext.cpp
  2. +1 −1 src/server/services/wms/qgswmsrendercontext.h
@@ -296,7 +296,7 @@ void QgsWmsRenderContext::initNicknameLayers()
{
for ( QgsMapLayer *ml : mProject->mapLayers() )
{
mNicknameLayers[ layerNickname( *ml ) ] = ml;
mNicknameLayers.insert( layerNickname( *ml ), ml );
}

// init groups
@@ -412,14 +412,15 @@ void QgsWmsRenderContext::searchLayersToRender()

if ( mFlags & AddQueryLayers )
{
const auto constLayers { flattenedQueryLayers() };
for ( const QString &layer : constLayers )
const QStringList queryLayerNames { flattenedQueryLayers() };
for ( const QString &layerName : queryLayerNames )
{
if ( mNicknameLayers.contains( layer )
&& !mLayersToRender.contains( mNicknameLayers[layer] ) )
{
mLayersToRender.append( mNicknameLayers[layer] );
}
const QList<QgsMapLayer *> layers = mNicknameLayers.values( layerName );
for ( QgsMapLayer *lyr : layers )
if ( !mLayersToRender.contains( lyr ) )
{
mLayersToRender.append( lyr );
}
}
}
}
@@ -455,7 +456,7 @@ void QgsWmsRenderContext::searchLayersToRenderSld()
if ( mNicknameLayers.contains( lname ) )
{
mSlds[lname] = namedElem;
mLayersToRender.append( mNicknameLayers[ lname ] );
mLayersToRender.append( mNicknameLayers.values( lname ) );
}
else if ( mLayerGroups.contains( lname ) )
{
@@ -491,7 +492,7 @@ void QgsWmsRenderContext::searchLayersToRenderStyle()
mStyles[nickname] = style;
}

mLayersToRender.append( mNicknameLayers[ nickname ] );
mLayersToRender.append( mNicknameLayers.values( nickname ) );
}
else if ( mLayerGroups.contains( nickname ) )
{
@@ -509,7 +510,7 @@ void QgsWmsRenderContext::searchLayersToRenderStyle()

for ( const auto &name : layersFromGroup )
{
mLayersToRender.append( mNicknameLayers[ name ] );
mLayersToRender.append( mNicknameLayers.values( name ) );
}
}
else
@@ -531,13 +532,16 @@ bool QgsWmsRenderContext::layerScaleVisibility( const QString &name ) const
return visible;
}

const QgsMapLayer *layer = mNicknameLayers[ name ];
bool scaleBasedVisibility = layer->hasScaleBasedVisibility();
bool useScaleConstraint = ( scaleDenominator() > 0 && scaleBasedVisibility );

if ( !useScaleConstraint || layer->isInScaleRange( scaleDenominator() ) )
const QList<QgsMapLayer *>layers = mNicknameLayers.values( name );
for ( QgsMapLayer *layer : layers )
{
visible = true;
bool scaleBasedVisibility = layer->hasScaleBasedVisibility();
bool useScaleConstraint = ( scaleDenominator() > 0 && scaleBasedVisibility );

if ( !useScaleConstraint || layer->isInScaleRange( scaleDenominator() ) )
{
visible = true;
}
}

return visible;
@@ -259,7 +259,7 @@ namespace QgsWms
double mScaleDenominator = -1.0;

// nickname of all layers defined within the project
QMap<QString, QgsMapLayer *> mNicknameLayers;
QMultiMap<QString, QgsMapLayer *> mNicknameLayers;

// map of layers to use for rendering
QList<QgsMapLayer *> mLayersToRender;

0 comments on commit b3be308

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