EnMAPBox.Qgis Interface
Issue #282
resolved
Problem
EnMAPBox.Qgis accessor methods fail in several cases and throw errors which are hardly to understand fro none-developers.
For example, `EnMAPBox.Qgis.activeBand(0)` throws an exception if the active layer is of type QgsVectorLayer.
Traceback (most recent call last):
File "C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\site-packages\hubdc\core.py", line 2499, in openRasterDataset
gdalDataset = gdal.Open(filename, eAccess)
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\site-packages\osgeo\gdal.py", line 3116, in Open
return _gdal.Open(*args)
RuntimeError: `C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\enmapboxtestdata\landcover_berlin_polygon.shp' not recognized as a supported file format.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\unittest\case.py", line 59, in testPartExecutor
yield
File "C:\PROGRA~1\QGIS3~1.6\apps\Python37\lib\unittest\case.py", line 615, in run
testMethod()
File "C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\enmapboxtesting\test_enmapbox.py", line 150, in test_Qgis
result1 = Qgis.activeBand(0)
File "C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\enmapbox\__init__.py", line 218, in activeBand
return cls.activeRaster().band(index=index)
File "C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\enmapbox\__init__.py", line 199, in activeRaster
return openRasterDataset(qgis.utils.iface.activeLayer().source())
File "C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\site-packages\hubdc\core.py", line 2501, in openRasterDataset
raise errors.InvalidGDALDatasetError(filename)
hubdc.hubdcerrors.InvalidGDALDatasetError: C:\Users\geo_beja\Repositories\QGIS_Plugins\enmap-box\enmapboxtestdata\landcover_berlin_polygon.shp
Recommendation
EnMAPBox.Qgis should react similar to QgisInterface.activeLayer() and return None in case there is no active layer / layer type they can understand.
Unit Test
A test is implemented in enmapboxtesting.test_enmapbox.TestEnMAPBox#test_Qgis
Comments (3)
-
reporter -
- changed status to resolved
fixed, unit test passes
-
fixed
#282→ <<cset 45e9c8a73a22>>
- Log in to comment
modifed test that addresses
#282Signed-off-by: benjamin.jakimow benjamin.jakimow@geo.hu-berlin.de
→ <<cset aa6643d8b2ef>>