EnMAP-Box / enmap-box

EnMAP-Box source code repository. See https://enmap-box.readthedocs.io for documentation
GNU General Public License v3.0
34 stars 16 forks source link

[SpectralLibraryUtils] SpectralLibraryUtils.writeToSource crashes, when using *.geojson filenames #926

Open janzandr opened 1 week ago

janzandr commented 1 week ago

How to reproduce:

from enmapbox import initAll
from enmapbox.qgispluginsupport.qps.speclib.core.spectrallibrary import SpectralLibraryUtils
from enmapbox.testing import start_app
from enmapboxtestdata import landcover_point
from qgis._core import QgsVectorLayer

start_app()
initAll()

layer = QgsVectorLayer(landcover_point)
filenameCopy = 'copy.geojson'
SpectralLibraryUtils.writeToSource(layer, filenameCopy)
layerCopy = QgsVectorLayer(filenameCopy)
assert layerCopy.isValid()

Python logs:

ERROR 1: Geometry extent outside of [-180.0,180.0]x[-90.0,90.0] bounds
ERROR 1: Geometry extent outside of [-180.0,180.0]x[-90.0,90.0] bounds
ERROR 1: Geometry extent outside of [-180.0,180.0]x[-90.0,90.0] bounds
ERROR 1: Geometry extent outside of [-180.0,180.0]x[-90.0,90.0] bounds
ERROR 1: Geometry extent outside of [-180.0,180.0]x[-90.0,90.0] bounds
Traceback (most recent call last):
  File "D:\QGIS\apps\Python312\Lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "D:\pycharm\PyCharm 2022.2.1\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pycharm\PyCharm 2022.2.1\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/source/QGISPlugIns/enmap-box/tests/enmap-box/enmapboxprocessing/algorithm/_a.py", line 12, in <module>
    SpectralLibraryUtils.writeToSource(layer, filenameCopy)
  File "D:\source\QGISPlugIns\enmap-box\enmapbox\qgispluginsupport\qps\speclib\core\spectrallibrary.py", line 313, in writeToSource
    return SpectralLibraryIO.writeToSource(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\source\QGISPlugIns\enmap-box\enmapbox\qgispluginsupport\qps\speclib\core\spectrallibraryio.py", line 500, in writeToSource
    create_files = IO.exportProfiles(path_dst, profiles, exportSettings=dst_settings, feedback=feedback)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\source\QGISPlugIns\enmap-box\enmapbox\qgispluginsupport\qps\speclib\io\geojson.py", line 243, in exportProfiles
    if writer.errorCode() != QgsVectorFileWriter.NoError:
       ^^^^^^^^^^^^^^^^
AttributeError: 'QgsVectorFileWriter' object has no attribute 'errorCode'

This bug is probably related to EnMAP-Box/qgispluginsupport#54