Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wmts] Check that we've got a file path before attempting to parse it #84

Merged
merged 2 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
gacarrillor marked this conversation as resolved.
Show resolved Hide resolved
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