Skip to content

Commit

Permalink
fix basemap detection, fix #22
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldo committed Sep 19, 2024
1 parent e425bd6 commit 4d03c99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions layertree2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def stripAccents(self, str):
def getDataProvider(self, layerId, type):
# https://gis.stackexchange.com/a/447119/60146
layer = QgsProject.instance().mapLayer(layerId)
uri_components = QgsProviderRegistry.instance().decodeUri(layer.dataProvider().name(), layer.publicSource());
uri_components = QgsProviderRegistry.instance().decodeUri(layer.dataProvider().name(), layer.publicSource())

if type and type in uri_components:
return uri_components[type]
Expand Down Expand Up @@ -322,7 +322,9 @@ def getLayerTree(self, node):
obj['vectorial'] = vectorial

# base layer
if str(node.layer().type()) == 'QgsMapLayerType.RasterLayer' and node.layer().providerType() == 'wms':
print(node.name(), node.layer().type())
# breaking change: 'QgsMapLayerType.RasterLayer' renamed to 'LayerType.Raster'
if (str(node.layer().type()) == 'QgsMapLayerType.RasterLayer' or str(node.layer().type()) == 'LayerType.Raster') and node.layer().providerType() == 'wms':

obj['type'] = "baselayer"
obj['url'] = self.getDataProvider(node.layerId(), 'url')
Expand Down
3 changes: 2 additions & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name=LayerTree2JSON
qgisMinimumVersion=3.0
description=Parse QGIS 3 project and write a JSON config file with layer information.
version=0.7
version=0.7.1
author=Gerald Kogler
email=geraldo@servus.at

Expand All @@ -22,6 +22,7 @@ deprecated=False
server=False

changelog=
0.7.1 - Fix detection of basemap layers (#22)
0.7 - Remove dependency from pysftp (#21)
0.6.1 - Fix initial plugin load issue (#20)
0.6 - Add support for project files saved in PostgreSQL
Expand Down

0 comments on commit 4d03c99

Please sign in to comment.