sydroconsult / QTalsim

QTalsim is a QGIS plugin designed to create hyrological response units (HRUs) suitable for Talsim
2 stars 2 forks source link

Python error when trying to connect to Talsim-DB from QGIS project containing raster layers #3

Closed jamaa closed 5 months ago

jamaa commented 6 months ago

Using v1.2.0:

Clicking on "Connect to Talsim DB" produces the following Python error:

2024-03-25T08:37:26     WARNING    Traceback (most recent call last):
              File "C:\Users/felixfroehlich/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QTalsim\qtalsim.py", line 2213, in open_sql_connect_dock
              self.sqlConnect = SQLConnectDialog(self.iface.mainWindow(), self)
              File "C:\Users/felixfroehlich/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QTalsim\qtalsim_sqllite_dialog.py", line 28, in __init__
              self.initialize_parameters()
              File "C:\Users/felixfroehlich/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QTalsim\qtalsim_sqllite_dialog.py", line 57, in initialize_parameters
              layers = self.getAllLayers(self.root)
              File "C:\Users/felixfroehlich/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QTalsim\qtalsim.py", line 2032, in getAllLayers
              layers.extend(self.getAllLayers(child))
              File "C:\Users/felixfroehlich/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QTalsim\qtalsim.py", line 2036, in getAllLayers
              if layer.geometryType() == QgsWkbTypes.PolygonGeometry:
             AttributeError: 'QgsRasterLayer' object has no attribute 'geometryType'

I suspect this is because getAllLayers is iterating over all layers in the project, and in my case, some of them are raster layers, which behave a bit differently.

lorenz3tla commented 5 months ago

Fixed with v1.3.0.