Skip to content
Permalink
Browse files
[Server] Fix the selection method in server renderer
The server feature id is a string and can be based on primary key attributes.
The server renderer selection method does not take this into account.
  • Loading branch information
rldhont authored and nyalldawson committed May 31, 2021
1 parent bd9fd63 commit 7498a1c8384b355296b7b3a16e285424472b2703
Showing with 17 additions and 12 deletions.
  1. +17 −12 src/server/services/wms/qgswmsrenderer.cpp
@@ -3109,17 +3109,22 @@ namespace QgsWms

void QgsRenderer::setLayerSelection( QgsMapLayer *layer, const QStringList &fids ) const
{
if ( layer->type() == QgsMapLayerType::VectorLayer )
if ( !fids.empty() && layer->type() == QgsMapLayerType::VectorLayer )
{
QgsFeatureIds selectedIds;
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );

QgsFeatureRequest request;
QgsServerFeatureId::updateFeatureRequestFromServerFids( request, fids, vl->dataProvider() );
const QgsFeatureIds selectedIds = request.filterFids();

for ( const QString &id : fids )
if ( selectedIds.empty() )
{
selectedIds.insert( STRING_TO_FID( id ) );
vl->selectByExpression( request.filterExpression()->expression() );
}
else
{
vl->selectByIds( selectedIds );
}

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
vl->selectByIds( selectedIds );
}
}

@@ -3236,6 +3241,11 @@ namespace QgsWms
setLayerFilter( layer, param.mFilter );
}

if ( mContext.testFlag( QgsWmsRenderContext::SetAccessControl ) )
{
setLayerAccessControlFilter( layer );
}

if ( mContext.testFlag( QgsWmsRenderContext::UseSelection ) )
{
setLayerSelection( layer, param.mSelection );
@@ -3245,11 +3255,6 @@ namespace QgsWms
{
updateExtent( layer, *settings );
}

if ( mContext.testFlag( QgsWmsRenderContext::SetAccessControl ) )
{
setLayerAccessControlFilter( layer );
}
}

if ( mContext.testFlag( QgsWmsRenderContext::AddHighlightLayers ) )

0 comments on commit 7498a1c

Please sign in to comment.