QGEP / qgepqwat2ili

3 stars 3 forks source link

Crash if there are no labels on export #149

Open sjib opened 1 week ago

sjib commented 1 week ago

Describe the bug

Ein Fehler trat bei der Ausführung von Python-Code auf: 

KeyError: 'crs' 
Traceback (most recent call last):
  File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\gui\__init__.py", line 620, in action_do_export
    qgepdss_export(selection=export_dialog.selected_ids, labels_file=labels_file_path, orientation=eorientation)
  File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\qgepdss\export.py", line 3765, in qgep_export
    geojson_crs_def = labels["crs"]
KeyError: 'crs'

Python-Version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] 
QGIS-Version: 3.28.4-Firenze Firenze, fd0fb72ab3 

Python-Pfad:
C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\generate_swmm_inp
C:/PROGRA~1/QGIS 3.28.4/apps/qgis-ltr/./python
C:/Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS 3.28.4/apps/qgis-ltr/./python/plugins
C:\Program Files\QGIS 3.28.4\bin\python39.zip
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\DLLs
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\lib
C:\Program Files\QGIS 3.28.4\bin
C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages
C:\PROGRA~1\QGIS 3.28.4\apps\Python39
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\lib\site-packages
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\lib\site-packages\win32
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\lib\site-packages\Pythonwin
C:/Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Daten/QGEP/testing_importspeed
C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\gui\..\..
C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\gui\..\..
.

To Reproduce Exact steps to reproduce the behavior:

  1. Select just one reach that has not complete information as eg. levels etc.
  2. Choose export with labels
  3. If no labels are generated then this error appears

Expected behavior No crash of code in this case

Screenshots / data If applicable, add screenshots or data to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

sjib commented 1 week ago

If the created labels.json looks like this - then there is no "crs" that can be found.

{
"type": "FeatureCollection",
"name": "labels",
"features": [

]
}

to do: check whether this check is correct:

https://github.com/QGEP/qgepqwat2ili/blob/9c28c0ec463f26f3a83dff047e183dbf7ef0f90b/qgepqwat2ili/processing_algs/extractlabels_interlis.py#L173

 if labels_count == 0:
                continue