Skip to content

Commit

Permalink
Fix layers added twice
Browse files Browse the repository at this point in the history
  • Loading branch information
pathmapper committed Sep 23, 2024
1 parent 7c2a4a4 commit f861502
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
48 changes: 26 additions & 22 deletions luftbildfinder_nrw.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,29 +368,33 @@ def selected_years():
new_group = root.insertGroup(0, group_name)

metadata_layers = []
added_layers = set()
for year, date, service, infolayer, layer in selected_years:
if not any(item[1] == infolayer for item in metadata_layers):
metadata_layers.append((service, infolayer))
BASE_URL = f"https://www.wms.nrw.de/geobasis/{service}"
urlWithParams = f"crs=EPSG:25832&format=image/png&layers={layer}&styles&url={BASE_URL}"
rlayer = QgsRasterLayer(urlWithParams, f"Luftbild {layer}", "wms")
if not rlayer.isValid():
pass
else:
QgsProject.instance().addMapLayer(rlayer, False)
new_group.insertLayer(-1, rlayer)
rlayerNode = root.findLayer(rlayer.id())
rlayerNode.setExpanded(False)
QgsProject.instance().addMapLayer(rlayer)

self.canvas.flashGeometries(
[QgsGeometry.fromPointXY(original_pt)],
source_crs,
QColor(255, 0, 0, 255),
QColor(255, 0, 0, 255),
int(10),
int(500),
)
if layer not in added_layers:
if not any(item[1] == infolayer for item in metadata_layers):
metadata_layers.append((service, infolayer))
BASE_URL = f"https://www.wms.nrw.de/geobasis/{service}"
urlWithParams = f"crs=EPSG:25832&format=image/png&layers={layer}&styles&url={BASE_URL}"
rlayer = QgsRasterLayer(urlWithParams, f"Luftbild {layer}", "wms")
if not rlayer.isValid():
pass
else:
QgsProject.instance().addMapLayer(rlayer, False)
new_group.insertLayer(-1, rlayer)
rlayerNode = root.findLayer(rlayer.id())
rlayerNode.setExpanded(False)
QgsProject.instance().addMapLayer(rlayer)

added_layers.add(layer)

self.canvas.flashGeometries(
[QgsGeometry.fromPointXY(original_pt)],
source_crs,
QColor(255, 0, 0, 255),
QColor(255, 0, 0, 255),
int(10),
int(500),
)

if self.add_metadata_layer:
for service, infolayer in metadata_layers:
Expand Down
6 changes: 4 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ about=Remark:
- iDOP
- vDOP
tags=dop,idop,vdop,luftbild,luftbilder,nrw
version=0.4.0
version=0.5.0
qgisMinimumVersion=3.16
author=Kreis Viersen
email=open@kreis-viersen.de
Expand All @@ -24,7 +24,9 @@ icon=luftbildfinder-nrw.png

server=False
deprecated=False
changelog=v0.4.0:
changelog=v0.5.0:
- füge Layer bei bestimmten Konstellationen nicht doppelt hinzu
v0.4.0:
- behalte Auswahl wenn Sortierreihenfolge geändert wird
v0.3.0
- behebe Fehler bei Option Metadatenlayer
Expand Down

0 comments on commit f861502

Please sign in to comment.