BRGM / gml_application_schema_toolbox

GML Application Schema toolbox is a QGIS plugin allowing to manipulate OGC Complex Features
https://brgm.github.io/gml_application_schema_toolbox/
GNU General Public License v2.0
26 stars 17 forks source link

QgsProcessingException when loading GMLAS #263

Open kannes opened 1 year ago

kannes commented 1 year ago

Environment

Description

Trying to load a layer from a WFS using the wizard with GMLAS results in an error for me:

_core.QgsProcessingException: Kann Algorithmus nicht ausführen Konnte Quelllayer für INPUT nicht laden: keine Wert für Parameter angegeben 
Traceback (most recent call last):
  File "[...]/python/plugins/gml_application_schema_toolbox/gui/load_wizard.py", line 202, in validatePage
    self._panel.do_load()
  File "[...]/python/plugins/gml_application_schema_toolbox/gui/import_gmlas_panel.py", line 402, in do_load
    self.translate_processing(params)
  File "[...]/python/plugins/gml_application_schema_toolbox/gui/gmlas_panel_mixin.py", line 106, in translate_processing
    res = processing.run("gdal:convertformat", params, feedback=feedback)
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 181, in runAlgorithm
    raise QgsProcessingException(msg)
_core.QgsProcessingException: Kann Algorithmus nicht ausführen
Konnte Quelllayer für INPUT nicht laden: keine Wert für Parameter angegeben

The german message says that there was no value passed for the parameter INPUT.

The code path confirms that: https://github.com/BRGM/gml_application_schema_toolbox/blob/f40f85f02fac714217c0278ae1f47d93dd6270e7/gml_application_schema_toolbox/gui/import_gmlas_panel.py#L314-L319

I already tried changing that to INPUT but then I get another QgsProcessingException about the file path not being found (GMLAS:/tmp/tmpfudmiwrq.gml). I guess the prefix is the issue, the file exists. My GDAL should support GMLAS, ogrinfo GMLAS:/tmp/tmpfudmiwrq.gml lists 25 layers in it.

The QGIS docs for gdal:convertformat do not list a INPUT_FILE parameter so I guess it is simply swallowed in any case?

To Reproduce

Steps to reproduce the behavior:

  1. Have a clean profile, install 1.4.0-beta6
  2. Add a new spatialite database in the QGIS browser, otherwise the plugin will show a warning message bar and crash earlier
  3. Add https://www.gds.hessen.de/wfs2/aaa-suite/cgi-bin/alkis/vereinf/wfs as WFS connection to QGIS
  4. Launch the plugin
  5. "Load (wizard)" -> "WFS" -> "Connect" -> pick "Ave:VerwaltungsEinheit" -> "Load in relational mode (GMLAS)" -> pick the database
  6. After the last step, the described crash will happen

Expected behavior

I guess the data should get loaded as layer?


Additional Context

get_db_format crash

Without an available spatialite database, the plugin would crash with:

AttributeError: 'DatabaseWidget' object has no attribute 'get_db_format' 
Traceback (most recent call last):
  File "[...]/python/plugins/gml_application_schema_toolbox/gui/load_wizard.py", line 202, in validatePage
    self._panel.do_load()
  File "[...]/python/plugins/gml_application_schema_toolbox/gui/import_gmlas_panel.py", line 376, in do_load
    db_format = self.databaseWidget.get_db_format
AttributeError: 'DatabaseWidget' object has no attribute 'get_db_format'

I checked "get_db_format in dir(self.databaseWidget) == True to be true, no idea what's going on there...

Also not working with internal gmlas:convertformat_gmlas algorithm

When I changed the if clause in https://github.com/BRGM/gml_application_schema_toolbox/blob/607accd5fc69892878d432694947517bdb7acb2b/gml_application_schema_toolbox/gui/gmlas_panel_mixin.py#L99 to always use the gmlas:convertformat_gmlas algorithm instead, it also crashed saying that the INPUT file could not be found.

Logs

2023-02-08T16:09:26     INFO    Temporary configuration file created '/tmp/gmlasconf_zg052uvi.xml' for conversion.
2023-02-08T16:09:26     INFO    200
2023-02-08T16:09:33     NONE    GDAL OPTIONS: ['-f SQLite', '-oo CONFIG_FILE=/tmp/gmlasconf_zg052uvi.xml', '-oo EXPOSE_METADATA_LAYERS=YES', '-nlt CONVERT_TO_LINEAR', '-dsco SPATIALITE=YES', '-lco SRID=4326', '-forceNullable']
2023-02-08T16:09:33     NONE    gdal:convertformat with params = {'INPUT_FILE': 'GMLAS:/tmp/tmpcimli119.gml', 'CONVERT_ALL_LAYERS': True, 'OPTIONS': '-f SQLite -oo CONFIG_FILE=/tmp/gmlasconf_zg052uvi.xml -oo EXPOSE_METADATA_LAYERS=YES -nlt CONVERT_TO_LINEAR -dsco SPATIALITE=YES -lco SRID=4326 -forceNullable', 'OUTPUT': '/tmp/asd.sqlite'}
kannes commented 1 year ago

Seems like it was simply not tested and fully implemented on newer QGIS. As a workaround I removed the if clause to always use the internal gmlas:convertformat_gmlas algorithm. In that case one must not tinker with the INPUT_FILE parameter as I did above, INPUT_FILE is correct then, INPUT is not.