Skip to content
Permalink
Browse files

[WMSServer] Add unit test for non queryable layer in getfeatureinfo o…

…peration, add special case for group.
  • Loading branch information
tcoupin committed Jul 26, 2018
1 parent fd5c8e7 commit 0c18d3bc0a36e70ac0877219710ed728f07c5c2a
@@ -947,7 +947,7 @@ namespace QgsWms
// remove unwanted layers (restricted layers, ...)
removeUnwantedLayers( layers, scaleDenominator );
// remove non identifiable layers
removeNonIdentifiableLayers( layers );
//removeNonIdentifiableLayers( layers );

Q_FOREACH ( QgsMapLayer *layer, layers )
{
@@ -1245,13 +1245,16 @@ namespace QgsWms
Q_FOREACH ( QString queryLayer, queryLayers )
{
bool validLayer = false;
bool queryableLayer = false;
bool queryableLayer = true;
Q_FOREACH ( QgsMapLayer *layer, layers )
{
if ( queryLayer == layerNickname( *layer ) )
{
validLayer = true;
queryableLayer = !mProject->nonIdentifiableLayers().contains( layer->id() );
queryableLayer = !mProject->nonIdentifiableLayers().contains( layer->id() ) ;
if (!queryableLayer){
break;
}

QDomElement layerElement;
if ( infoFormat == QgsWmsParameters::Format::GML )
@@ -1314,16 +1317,16 @@ namespace QgsWms
break;
}
}
if ( !queryableLayer )
{
QString msg = QObject::tr( "Layer '%1' is not queryable" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotQueryable" ), msg );
}
else if ( !validLayer && !mNicknameLayers.contains( queryLayer ) )
if ( !validLayer && !mNicknameLayers.contains( queryLayer ) && !mLayerGroups.contains( queryLayer ) )
{
QString msg = QObject::tr( "Layer '%1' not found" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ), msg );
}
else if ( (validLayer && !queryableLayer) || (!validLayer && mLayerGroups.contains( queryLayer )) )
{
QString msg = QObject::tr( "Layer '%1' is not queryable" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotQueryable" ), msg );
}
}

if ( featuresRect )
@@ -57,6 +57,33 @@ def testGetFeatureInfo(self):
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
'wms_getfeatureinfo-text-xml')

# Test getfeatureinfo on non queryable layer
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer3&styles=&' +
'info_format=text%2Fxml&transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=testlayer3&X=190&Y=320',
'wms_getfeatureinfo-testlayer3-notqueryable')

# Test getfeatureinfo on group without shortname (no queryable...)
self.wms_request_compare('GetFeatureInfo',
'&layers=groupwithoutshortname&styles=&' +
'info_format=text%2Fxml&transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=groupwithoutshortname&X=190&Y=320',
'wms_getfeatureinfo-groupwithoutshortname-notqueryable')

# Test getfeatureinfo on group with shortname (no queryable...)
self.wms_request_compare('GetFeatureInfo',
'&layers=group_name&styles=&' +
'info_format=text%2Fxml&transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=group_name&X=190&Y=320',
'wms_getfeatureinfo-group_name-notqueryable')

# Test getfeatureinfo response html
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +

0 comments on commit 0c18d3b

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