From 4f13a856493d463ee8b466f05dc722dd1f1bf11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 21 May 2024 15:54:20 -0500 Subject: [PATCH 1/2] [wmts] Check that we've got a file path before attempting to parse it --- swiss_locator/core/filters/swiss_locator_filter_wmts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swiss_locator/core/filters/swiss_locator_filter_wmts.py b/swiss_locator/core/filters/swiss_locator_filter_wmts.py index 71e58dd..16e4445 100644 --- a/swiss_locator/core/filters/swiss_locator_filter_wmts.py +++ b/swiss_locator/core/filters/swiss_locator_filter_wmts.py @@ -55,7 +55,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}" @@ -91,7 +91,7 @@ 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()}" ) From 9703a2d715875ad092329bdd1365592286d36c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Wed, 22 May 2024 08:20:28 -0500 Subject: [PATCH 2/2] [wmts] Log error message if there were troubles downloading capabilities --- swiss_locator/core/filters/swiss_locator_filter_wmts.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/swiss_locator/core/filters/swiss_locator_filter_wmts.py b/swiss_locator/core/filters/swiss_locator_filter_wmts.py index 16e4445..7592178 100644 --- a/swiss_locator/core/filters/swiss_locator_filter_wmts.py +++ b/swiss_locator/core/filters/swiss_locator_filter_wmts.py @@ -22,6 +22,7 @@ from qgis.gui import QgisInterface from qgis.core import ( + Qgis, QgsApplication, QgsBlockingNetworkRequest, QgsFetchedContent, @@ -96,6 +97,11 @@ def handle_capabilities_response(self): 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 = {