Skip to content

Commit

Permalink
Merge pull request #33126 from signedav/rulelabelfix_bp
Browse files Browse the repository at this point in the history
Display Rulelabel when requested in GetLegendGraphics
  • Loading branch information
signedav committed Dec 10, 2019
2 parents ffe31ee + eac999c commit 30376b1
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/server/services/wms/qgswmsgetlegendgraphics.cpp
Expand Up @@ -236,7 +236,6 @@ namespace QgsWms

// layer titles - hidden or not
QgsLegendRenderer::setNodeLegendStyle( nodeLayer, parameters.layerTitleAsBool() ? QgsLegendStyle::Subgroup : QgsLegendStyle::Hidden );

// rule item titles
if ( !parameters.ruleLabelAsBool() )
{
Expand All @@ -246,7 +245,7 @@ namespace QgsWms
legendNode->setUserLabel( QStringLiteral( " " ) );
}
}
else if ( !parameters.layerTitleAsBool() )
else if ( !parameters.layerTitleAsBool() && model->layerLegendNodes( nodeLayer, true ).count() )
{
for ( QgsLayerTreeModelLegendNode *legendNode : model->layerLegendNodes( nodeLayer ) )
{
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgsserver_cachemanager.py
Expand Up @@ -333,6 +333,7 @@ def test_getlegendgraphic(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand Down
66 changes: 62 additions & 4 deletions tests/src/python/test_qgsserver_wms_getlegendgraphic.py
Expand Up @@ -93,6 +93,7 @@ def test_wms_getLegendGraphics_invalid_parameters(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello,db_point",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand Down Expand Up @@ -174,11 +175,34 @@ def test_wms_getLegendGraphics_layertitle(self):
'ITEMFONTFAMILY': self.fontFamily,
'ITEMFONTSIZE': '20',
'LAYERTITLE': 'TRUE',
'RULELABEL': 'TRUE'
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_test", 250, QSize(15, 15))

# no set of LAYERTITLE and RULELABEL means they are true
parms = {
'MAP': self.testdata_path + "test_project.qgs",
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
# 'WIDTH': '20', # optional
# 'HEIGHT': '20', # optional
'LAYER': u'testlayer%20èé',
'LAYERFONTBOLD': 'TRUE',
'LAYERFONTSIZE': '30',
'ITEMFONTBOLD': 'TRUE',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'ITEMFONTSIZE': '20'
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
r, h = self._result(self._execute_request(qs))

self._img_diff_error(r, h, "WMS_GetLegendGraphic_test", 250, QSize(15, 15))

parms = {
'MAP': self.testdata_path + "test_project.qgs",
'SERVICE': 'WMS',
Expand All @@ -189,6 +213,7 @@ def test_wms_getLegendGraphics_layertitle(self):
# 'HEIGHT': '20', # optional
'LAYER': u'testlayer%20èé',
'LAYERTITLE': 'FALSE',
'RULELABEL': 'FALSE'
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
r, h = self._result(self._execute_request(qs))
Expand All @@ -205,16 +230,37 @@ def test_wms_getLegendGraphics_rulelabel(self):
'LAYER': u'testlayer%20èé',
'LAYERFONTBOLD': 'TRUE',
'LAYERFONTSIZE': '30',
'ITEMFONTBOLD': 'TRUE',
'ITEMFONTSIZE': '20',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'RULELABEL': 'FALSE'
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rulelabel_false", 250, QSize(15, 15))

parms = {
'MAP': self.testdata_path + "test_project.qgs",
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
'LAYER': u'testlayer%20èé',
'LAYERFONTBOLD': 'TRUE',
'LAYERFONTSIZE': '30',
'ITEMFONTBOLD': 'TRUE',
'ITEMFONTSIZE': '20',
'RULELABEL': 'TRUE',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'LAYERTITLE': 'FALSE',
'RULELABEL': 'TRUE'
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_test", 250, QSize(15, 15))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rulelabel_true", 250, QSize(15, 15))

# no set of RULELABEL means it is true
parms = {
'MAP': self.testdata_path + "test_project.qgs",
'SERVICE': 'WMS',
Expand All @@ -228,11 +274,11 @@ def test_wms_getLegendGraphics_rulelabel(self):
'ITEMFONTSIZE': '20',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'RULELABEL': 'FALSE',
'LAYERTITLE': 'FALSE'
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rulelabel_false", 250, QSize(15, 15))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rulelabel_true", 250, QSize(15, 15))

def test_wms_getLegendGraphics_rule(self):
"""Test that does not return an exception but an image"""
Expand Down Expand Up @@ -274,6 +320,7 @@ def test_wms_GetLegendGraphic_Basic(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand All @@ -291,6 +338,7 @@ def test_wms_GetLegendGraphic_Transparent(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand All @@ -309,6 +357,7 @@ def test_wms_GetLegendGraphic_Background(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand All @@ -326,6 +375,7 @@ def test_wms_GetLegendGraphic_Background(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand All @@ -344,6 +394,7 @@ def test_wms_GetLegendGraphic_BoxSpace(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"BOXSPACE": "100",
"FORMAT": "image/png",
"HEIGHT": "500",
Expand All @@ -362,6 +413,7 @@ def test_wms_GetLegendGraphic_SymbolSpace(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"SYMBOLSPACE": "100",
"FORMAT": "image/png",
"HEIGHT": "500",
Expand All @@ -380,6 +432,7 @@ def test_wms_GetLegendGraphic_IconLabelSpace(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"ICONLABELSPACE": "100",
"FORMAT": "image/png",
"HEIGHT": "500",
Expand All @@ -398,6 +451,7 @@ def test_wms_GetLegendGraphic_SymbolSize(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"SYMBOLWIDTH": "50",
"SYMBOLHEIGHT": "30",
"FORMAT": "image/png",
Expand Down Expand Up @@ -465,6 +519,7 @@ def test_wms_GetLegendGraphic_BBox(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello,db_point",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"SRCHEIGHT": "500",
"SRCWIDTH": "500",
Expand All @@ -483,6 +538,7 @@ def test_wms_GetLegendGraphic_BBox2(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello,db_point",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"SRCHEIGHT": "500",
"SRCWIDTH": "500",
Expand All @@ -501,6 +557,7 @@ def test_wms_GetLegendGraphic_BBox_Fallback(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello,db_point",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand All @@ -519,6 +576,7 @@ def test_wms_GetLegendGraphic_BBox2_Fallback(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello,db_point",
"LAYERTITLE": "FALSE",
"RULELABEL": "FALSE",
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 30376b1

Please sign in to comment.