Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #36153 from level2-gis/master
Server GetLegendGraphics add RULELABEL AUTO option
  • Loading branch information
signedav committed May 15, 2020
2 parents 26d5fb0 + 55dc369 commit 2e8e158
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/server/services/wms/qgswmsgetlegendgraphics.cpp
Expand Up @@ -266,6 +266,7 @@ namespace QgsWms
if ( parameters.rule().isEmpty() )
{
QList<QgsLayerTreeNode *> children = tree.children();
QString ruleLabel = parameters.ruleLabel();
for ( QgsLayerTreeNode *node : children )
{
if ( ! QgsLayerTree::isLayer( node ) )
Expand All @@ -284,10 +285,11 @@ namespace QgsWms
legendNode->setUserLabel( QStringLiteral( " " ) );
}
}
else if ( !parameters.layerTitleAsBool() && model->layerLegendNodes( nodeLayer, true ).count() )
else if ( ruleLabel.compare( QStringLiteral( "AUTO" ), Qt::CaseInsensitive ) == 0 )
{
for ( QgsLayerTreeModelLegendNode *legendNode : model->layerLegendNodes( nodeLayer ) )
{
//clearing label for single symbol
if ( legendNode->isEmbeddedInParent() )
legendNode->setEmbeddedInParent( false );
}
Expand Down Expand Up @@ -349,4 +351,3 @@ namespace QgsWms
return nullptr;
}
} // namespace QgsWms

17 changes: 16 additions & 1 deletion tests/src/python/test_qgsserver_wms_getlegendgraphic.py
Expand Up @@ -278,7 +278,22 @@ def test_wms_getLegendGraphics_rulelabel(self):
}
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_true", 250, QSize(15, 15))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rulelabel_notset", 250, QSize(15, 15))

# RULELABEL AUTO for single symbol means it is removed
parms = {
'MAP': self.testdata_path + "test_project.qgs",
'SERVICE': 'WMS',
'VERSION': '1.3.0',
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
'LAYER': u'testlayer%20èé',
'LAYERTITLE': 'FALSE',
'RULELABEL': 'AUTO'
}
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_auto", 250, QSize(15, 15))

def test_wms_getLegendGraphics_rule(self):
"""Test that does not return an exception but an image"""
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.

0 comments on commit 2e8e158

Please sign in to comment.