Skip to content
Permalink
Browse files

WMS server: use shortName of group GetMap and check if the layer is q…

…ueryable (or not for group, GetFeaureInfo)
  • Loading branch information
tcoupin committed Jul 23, 2018
1 parent 8060736 commit 6a68309989aa8d078309a160850b21bfb579039e
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/server/services/wms/qgswmsrenderer.cpp
@@ -1241,11 +1241,13 @@ namespace QgsWms
Q_FOREACH ( QString queryLayer, queryLayers )
{
bool validLayer = false;
bool queryableLayer = false;
Q_FOREACH ( QgsMapLayer *layer, layers )
{
if ( queryLayer == layerNickname( *layer ) )
{
validLayer = true;
queryableLayer = !mProject->nonIdentifiableLayers().contains( layer->id() );

QDomElement layerElement;
if ( infoFormat == QgsWmsParameters::Format::GML )
@@ -1308,8 +1310,12 @@ namespace QgsWms
break;
}
}

if ( !validLayer && !mNicknameLayers.contains( queryLayer ) )
if ( !queryableLayer )
{
QString msg = QObject::tr( "Layer '%1' is not queryable" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotQueryable" ), msg );
}
else if ( !validLayer && !mNicknameLayers.contains( queryLayer ) )
{
QString msg = QObject::tr( "Layer '%1' not found" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ), msg );
@@ -2416,7 +2422,12 @@ namespace QgsWms
{
if ( child->nodeType() == QgsLayerTreeNode::NodeGroup )
{
initLayerGroupsRecursive( static_cast<const QgsLayerTreeGroup *>( child ), child->name() );
QString shortName = child->customProperty( QStringLiteral( "wmsShortName" ) ).toString();
QString name = child->name();
if ( !shortName.isEmpty() )
initLayerGroupsRecursive( static_cast<const QgsLayerTreeGroup *>( child ), shortName );
else
initLayerGroupsRecursive( static_cast<const QgsLayerTreeGroup *>( child ), name );
}
}
}

0 comments on commit 6a68309

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