Skip to content

Commit

Permalink
Merge pull request #5519 from pblottiere/server_bugfix_layernotfoud
Browse files Browse the repository at this point in the history
[server][bugfix] Fixes #17400 by returning an empty response instead of an exception
  • Loading branch information
pblottiere authored Nov 10, 2017
2 parents fe56531 + 534e1e8 commit ecacb3b
Show file tree
Hide file tree
Showing 4 changed files with 656 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ namespace QgsWms
}
}

if ( !validLayer )
if ( !validLayer && !mNicknameLayers.contains( queryLayer ) )
{
QString msg = QObject::tr( "Layer '%1' not found" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ), msg );
Expand Down
19 changes: 17 additions & 2 deletions tests/src/python/test_qgsserver_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class TestQgsServerWMS(QgsServerTestBase):
# Set to True to re-generate reference files for this class
regenerate_reference = False

def wms_request_compare(self, request, extra=None, reference_file=None):
project = self.testdata_path + "test_project.qgs"
def wms_request_compare(self, request, extra=None, reference_file=None, project='test_project.qgs'):
project = self.testdata_path + project
assert os.path.exists(project), "Project file not found: " + project

query_string = 'https://www.qgis.org/?MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (urllib.parse.quote(project), request)
Expand Down Expand Up @@ -217,6 +217,21 @@ def test_getfeatureinfo(self):
'query_layers=testlayer+%C3%A8%C3%A9&X=190&Y=320',
'wms_getfeatureinfo-text-xml')

# layer1 is a clone of layer0 but with a scale visibility. Thus,
# GetFeatureInfo response contains only a feature for layer0 and layer1
# is ignored for the required bbox. Without the scale visibility option,
# the feature for layer1 would have been in the response too.
mypath = self.testdata_path + "test_project_scalevisibility.qgs"
self.wms_request_compare('GetFeatureInfo',
'&layers=layer0,layer1&styles=&' +
'VERSION=1.1.0&' +
'info_format=text%2Fxml&' +
'width=500&height=500&srs=EPSG%3A4326' +
'&bbox=8.1976,44.8998,8.2100,44.9027&' +
'query_layers=layer0,layer1&X=235&Y=243',
'wms_getfeatureinfo_notvisible',
'test_project_scalevisibility.qgs')

def test_describelayer(self):
# Test DescribeLayer
self.wms_request_compare('DescribeLayer',
Expand Down
Loading

0 comments on commit ecacb3b

Please sign in to comment.