Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #8950 from elpaso/bugfix-opengis-zug-wmsroot
Fix server WMS short name (unreported)
  • Loading branch information
elpaso committed Jan 23, 2019
2 parents e3516ab + 4e8898d commit de29767
Show file tree
Hide file tree
Showing 3 changed files with 1,993 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2548,8 +2548,9 @@ namespace QgsWms
}

// init groups
const QString rootName { QgsServerProjectUtils::wmsRootName( *mProject ) };
const QgsLayerTreeGroup *root = mProject->layerTreeRoot();
initLayerGroupsRecursive( root, mProject->title() );
initLayerGroupsRecursive( root, rootName.isEmpty() ? mProject->title() : rootName );
}

void QgsRenderer::initLayerGroupsRecursive( const QgsLayerTreeGroup *group, const QString &groupName )
Expand Down
41 changes: 41 additions & 0 deletions tests/src/python/test_qgsserver_wms_getlegendgraphic.py
Expand Up @@ -514,6 +514,47 @@ def test_wms_GetLegendGraphic_EmptyLegend(self):
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))

def test_wms_GetLegendGraphic_wmsRootName(self):
"""Test an unreported issue when a wmsRootName short name is set in the service capabilities"""

# First test with the project title itself:
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": self.testdata_path + 'test_project_wms_grouped_layers.qgs',
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetLegendGraphic",
"LAYER": "QGIS%20Server%20-%20Grouped%20Layer",
"FORMAT": "image/png",
"HEIGHT": "840",
"WIDTH": "1226",
"BBOX": "609152,5808188,625492,5814318",
"SRS": "EPSG:25832",
"SCALE": "38976"
}.items())])

h, r = self._execute_request(qs)
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))

# Then test with the wmsRootName short name:
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": self.testdata_path + 'test_project_wms_grouped_layers_wmsroot.qgs',
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetLegendGraphic",
"LAYER": "All_grouped_layers",
"FORMAT": "image/png",
"HEIGHT": "840",
"WIDTH": "1226",
"BBOX": "609152,5808188,625492,5814318",
"SRS": "EPSG:25832",
"SCALE": "38976"
}.items())])

h, r = self._execute_request(qs)
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))


if __name__ == '__main__':
unittest.main()

0 comments on commit de29767

Please sign in to comment.