Skip to content
Permalink
Browse files

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 2e8e158cb8576bca2dcd880cecbe578d1b4ace5b
@@ -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 ) )
@@ -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 );
}
@@ -349,4 +351,3 @@ namespace QgsWms
return nullptr;
}
} // namespace QgsWms

@@ -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"""
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 2e8e158

Please sign in to comment.
You can’t perform that action at this time.