Skip to content

Commit

Permalink
Adding WMS as Surface Throws Error #544
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyMWhitehead authored and philipbaileynar committed Dec 13, 2024
1 parent 4f9a18c commit 9d4417e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/gp/feature_class_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand Down
9 changes: 7 additions & 2 deletions src/view/frm_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit 9d4417e

Please sign in to comment.