Skip to content

Commit ac1b492

Browse files
elpasonyalldawson
authored andcommittedFeb 6, 2019
Merge pull request #8950 from elpaso/bugfix-opengis-zug-wmsroot
Fix server WMS short name (unreported) Cherry-picked from master de29767
1 parent 0baf3fa commit ac1b492

File tree

3 files changed

+1993
-1
lines changed

3 files changed

+1993
-1
lines changed
 

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2425,8 +2425,9 @@ namespace QgsWms
24252425
}
24262426

24272427
// init groups
2428+
const QString rootName { QgsServerProjectUtils::wmsRootName( *mProject ) };
24282429
const QgsLayerTreeGroup *root = mProject->layerTreeRoot();
2429-
initLayerGroupsRecursive( root, mProject->title() );
2430+
initLayerGroupsRecursive( root, rootName.isEmpty() ? mProject->title() : rootName );
24302431
}
24312432

24322433
void QgsRenderer::initLayerGroupsRecursive( const QgsLayerTreeGroup *group, const QString &groupName )

‎tests/src/python/test_qgsserver_wms_getlegendgraphic.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,47 @@ def test_wms_GetLegendGraphic_EmptyLegend(self):
488488
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
489489
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))
490490

491+
def test_wms_GetLegendGraphic_wmsRootName(self):
492+
"""Test an unreported issue when a wmsRootName short name is set in the service capabilities"""
493+
494+
# First test with the project title itself:
495+
qs = "?" + "&".join(["%s=%s" % i for i in list({
496+
"MAP": self.testdata_path + 'test_project_wms_grouped_layers.qgs',
497+
"SERVICE": "WMS",
498+
"VERSION": "1.1.1",
499+
"REQUEST": "GetLegendGraphic",
500+
"LAYER": "QGIS%20Server%20-%20Grouped%20Layer",
501+
"FORMAT": "image/png",
502+
"HEIGHT": "840",
503+
"WIDTH": "1226",
504+
"BBOX": "609152,5808188,625492,5814318",
505+
"SRS": "EPSG:25832",
506+
"SCALE": "38976"
507+
}.items())])
508+
509+
h, r = self._execute_request(qs)
510+
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
511+
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))
512+
513+
# Then test with the wmsRootName short name:
514+
qs = "?" + "&".join(["%s=%s" % i for i in list({
515+
"MAP": self.testdata_path + 'test_project_wms_grouped_layers_wmsroot.qgs',
516+
"SERVICE": "WMS",
517+
"VERSION": "1.1.1",
518+
"REQUEST": "GetLegendGraphic",
519+
"LAYER": "All_grouped_layers",
520+
"FORMAT": "image/png",
521+
"HEIGHT": "840",
522+
"WIDTH": "1226",
523+
"BBOX": "609152,5808188,625492,5814318",
524+
"SRS": "EPSG:25832",
525+
"SCALE": "38976"
526+
}.items())])
527+
528+
h, r = self._execute_request(qs)
529+
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
530+
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))
531+
491532

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

0 commit comments

Comments
 (0)
Please sign in to comment.