Skip to content

Commit

Permalink
Merge pull request #84 from gacarrillor/fix_51
Browse files Browse the repository at this point in the history
[wmts] Check that we've got a file path before attempting to parse it
  • Loading branch information
3nids authored May 22, 2024
2 parents 0e64bc7 + 9703a2d commit b9d7958
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions swiss_locator/core/filters/swiss_locator_filter_wmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from qgis.gui import QgisInterface
from qgis.core import (
Qgis,
QgsApplication,
QgsBlockingNetworkRequest,
QgsFetchedContent,
Expand Down Expand Up @@ -55,7 +56,7 @@ def __init__(self, iface: QgisInterface = None, crs: str = None, capabilities=No

self.info(self.content.status())

if self.content.status() == QgsFetchedContent.ContentStatus.Finished:
if self.content.status() == QgsFetchedContent.ContentStatus.Finished and self.content.filePath():
file_path = self.content.filePath()
self.info(
f"Swisstopo capabilities already downloaded. Reading from {file_path}"
Expand Down Expand Up @@ -91,11 +92,16 @@ def prefix(self):
return "chw"

def handle_capabilities_response(self):
if self.content.status() == QgsFetchedContent.ContentStatus.Finished:
if self.content.status() == QgsFetchedContent.ContentStatus.Finished and self.content.filePath():
self.info(
f"Swisstopo capabilities has been downloaded. Reading from {self.content.filePath()}"
)
self.capabilities = ET.parse(self.content.filePath()).getroot()
else:
self.info(
"The Swiss Locator filter for WMTS layers could not fetch capabilities",
Qgis.Critical
)

def perform_fetch_results(self, search: str, feedback: QgsFeedback):
namespaces = {
Expand Down

0 comments on commit b9d7958

Please sign in to comment.