From 1d78348785d21ee274c3fdb1df161f2a04ab8351 Mon Sep 17 00:00:00 2001 From: Kelly W Date: Fri, 13 Dec 2024 14:24:06 -0800 Subject: [PATCH] Adding WMS as Surface Throws Error #544 --- src/gp/feature_class_functions.py | 12 +++++++----- src/view/frm_basemap.py | 9 +++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gp/feature_class_functions.py b/src/gp/feature_class_functions.py index 3d0ac63..64808f2 100644 --- a/src/gp/feature_class_functions.py +++ b/src/gp/feature_class_functions.py @@ -2,13 +2,10 @@ from osgeo import ogr from osgeo import osr -from shapely.wkb import loads as wkbload, dumps as wkbdumps -from osgeo.gdal import Warp, WarpOptions -from qgis.PyQt.QtWidgets import QMessageBox -from qgis.core import QgsVectorLayer, QgsGeometry +from qgis.PyQt.QtWidgets import QMessageBox from qgis.gui import QgsDataSourceSelectDialog -from qgis.core import QgsMapLayer, QgsWkbTypes +from qgis.core import QgsMapLayer, QgsWkbTypes, QgsVectorLayer, QgsGeometry from qgis.utils import iface from ..model.db_item import DBItem @@ -171,6 +168,11 @@ def browse_raster(parent, description: str) -> str: uri = frm_browse.uri() if uri is not None and uri.isValid(): + # check if the raster exists on disk + if uri.providerKey != 'gdal': + QMessageBox.warning(parent, 'Invalid Raster', + f'This raster format is not currently supported by QRiS. Please select a different raster.') + return None # if uri extension is .vrt then it is a virtual raster and cannot be used vrt_ext = os.path.splitext(uri.uri)[1].lower() if vrt_ext == '.vrt': diff --git a/src/view/frm_basemap.py b/src/view/frm_basemap.py index a4c4f02..8c46eb5 100644 --- a/src/view/frm_basemap.py +++ b/src/view/frm_basemap.py @@ -63,7 +63,11 @@ def __init__(self, parent, iface, project: Project, import_source_path: str, is_ self.txtName.textChanged.connect(self.on_name_changed) self.txtSourcePath.textChanged.connect(self.on_name_changed) self.txtSourcePath.setText(import_source_path) - self.txtName.setText(os.path.splitext(os.path.basename(import_source_path))[0]) + name, ext = os.path.splitext(os.path.basename(import_source_path)) + gpkg = ext.split(':') + if gpkg[0].lower() in ['.gpkg', '.gdb']: + name = gpkg[1] + self.txtName.setText(name) # Attempt to parse the raster type from the source raster name if 'dem' in self.txtName.text().lower(): @@ -250,7 +254,8 @@ def on_name_changed(self, new_name): clean_name_hillshade = f'{clean_name}_hillshade' if len(project_name) > 0: - _name, ext = os.path.splitext(self.txtSourcePath.text()) + # _name, ext = os.path.splitext(self.txtSourcePath.text()) + ext = '.tif' # We are only saving files as tif parent_folder = CONTEXT_PARENT_FOLDER if self.is_context else SURFACES_PARENT_FOLDER self.txtProjectPath.setText(parse_posix_path(os.path.join(parent_folder, self.project.get_safe_file_name(clean_name, ext)))) self.hillshade_project_path = parse_posix_path(os.path.join(parent_folder, self.project.get_safe_file_name(clean_name_hillshade, ext)))