teksi / wastewater

[DEV] Future TEKSI wastewater module, adapted data model to fit VSA-DSS 2020 new standard
https://teksi.github.io/wastewater
GNU General Public License v3.0
2 stars 5 forks source link

UnboundLocalError: cannot access local variable 'vertex' where it is not associated with a value #456

Open sjib opened 2 weeks ago

sjib commented 2 weeks ago

Describe the bug A clear and concise description of what the bug is.

Run refresh network topology (on opening project or manually)

To Reproduce Exact steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

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

2024-10-12T20:21:10     CRITICAL    Error : Status 7 (FEHLER: storniere Anfrage wegen Zeitüberschreitung der Anfrage
             CONTEXT: SQL-Anweisung »REFRESH MATERIALIZED VIEW tww_app.vw_network_node«
             PL/pgSQL-Funktion tww_app.network_refresh_network_simple() Zeile 106 bei SQL-Anweisung
             )
2024-10-12T20:21:10     WARNING    Python-Fehler : Ein Fehler trat bei der Ausführung von Python-Code auf: Mehr Details im Protokoll (Python-Fehler).
2024-10-12T20:16:21     WARNING    Traceback (most recent call last):
              File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_pre_2024.0.2/python/plugins\teksi_wastewater\teksi_wastewater_plugin.py", line 446, in onLayersAvailable
              self.network_analyzer.setNodeLayer(layers["vw_network_node"])
              File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_pre_2024.0.2/python/plugins\teksi_wastewater\tools\twwnetwork.py", line 94, in setNodeLayer
              self.createGraph()
              File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_pre_2024.0.2/python/plugins\teksi_wastewater\tools\twwnetwork.py", line 219, in createGraph
              self._addVertices()
              File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_pre_2024.0.2/python/plugins\teksi_wastewater\tools\twwnetwork.py", line 116, in _addVertices
              self.graph.add_node(fid, point=vertex, objType=obj_type, objId=obj_id)
              ^^^^^^
             UnboundLocalError: cannot access local variable 'vertex' where it is not associated with a value

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Very big dataset - do we have a timeout somewhere in the code?

cymed commented 1 week ago

I think vertex was not populated because of a ValueError the the Try-Catch in

https://github.com/teksi/wastewater/blob/d48313e65ff600c57f9fc5649c9810d469e92701/plugin/teksi_wastewater/tools/twwnetwork.py#L111-L116

Are there wastewater nodes without geometry?

sjib commented 1 week ago

Then we should think about how to handle this and create a more meaningful error message.

sjib commented 1 week ago

And / or discuss whether 'Lage' should be MANDATORY in INTERLIS in the future?

!!@ comment = "Lage des Knotens, massgebender Bezugspunkt für die Kanalnetzberechnung. (In der Regel Lage des Pickellochs oder Lage des Trockenwetterauslaufs)" Lage: Base_LV95.LKoord; !!@ comment = "1. Massgebende Rückstaukote bezogen auf den Berechnungsregen (dss) 2. Höhe, unter der innerhalb der Grundstücksentwässerung besondere Massnahmen gegen Rückstau zu treffen sind. (DIN 4045)" Rueckstaukote_Ist: Base_LV95.Hoehe; !!@ comment = "Tiefster Punkt des Knotens. Bei Sonderbauwerken tiefster Punkt des Knotens zu dem die Stammkarte gehört, also in der Regel Auslauf Richtung ARA." Sohlenkote: Base_LV95.Hoehe; END Abwasserknoten;