[QGIS-Developer] Updating a WMS layer's legend with the same style as the one used by the data provider

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Fri Feb 8 07:49:47 PST 2019


Hi all

I have a working python code snippet that enables updating a WMS layer with
a different named style.

It basically manipulates the raster provider's `dataSourceUri` property,
replacing the `style=` with a different substring. and then it calls for a
reload of the data and triggers a repaint of the layer. Something like this:

```
provider = layer.dataProvider()
original_uri = provider.dataSourceUri()
new_uri = modify_uri(original_uri)
provider.setDataSourceUri(new_uri)
provider.reloadData()
provider.dataChanged.emit()
```

It is working fine and the layer is shown with the updated style. Now I'd
like to have also the layer's legend be refreshed with the correct style.

Is this possible?

I've tried

```
iface.layerTreeView().refreshLayerSymboogy(layer.id())
```

This does not work, I am monitoring the WMS server's logs and I don't see
any new `GetLegendGraphic` request being issued.

Thanks in advance

-- 
___________________________ ___ __
Ricardo Garcia Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190208/a3c1462c/attachment.html>


More information about the QGIS-Developer mailing list