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
0 stars 5 forks source link

Error with depth calculation when updating a node or cover #297

Open ponceta opened 1 month ago

ponceta commented 1 month ago

Describe the bug An error messages prompts when changing the postition of a node.

Couche vw_wastewater_node: 
Erreur PostGIS lors de la modification de géométrie : 
ERREUR: champ numérique en dehors des limites 
DETAIL: Un champ de précision 6 et d'échelle 3 doit être arrondi à une valeur absolue inférieure à 10^3. 
CONTEXT: instruction SQL « 
UPDATE tww_od.wastewater_structure ws 
SET _depth = depth 
FROM ( SELECT WS.obj_id, 
    CO.level - COALESCE(MIN(NO.bottom_level), 
    MIN(RP.level)) as depth 
    FROM tww_od.wastewater_structure WS 
    LEFT JOIN tww_od.cover CO on WS.fk_main_cover = CO.obj_id 
    LEFT JOIN tww_od.wastewater_networkelement NE ON NE.fk_wastewater_structure = WS.obj_id 
    RIGHT JOIN tww_od.wastewater_node NO on NO.obj_id = NE.obj_id 
    LEFT JOIN tww_od.reach_point RP ON RP.fk_wastewater_networkelement = NE.obj_id 
    WHERE _all OR WS.obj_id = _obj_id 
GROUP BY WS.obj_id, CO.level ) ws_depths 
where ws.obj_id = ws_depths.obj_id 
» fonction PL/pgSQL tww_app.update_depth(text,boolean), 
ligne 6 à instruction SQL fonction PL/pgSQL tww_app.on_wasterwaternode_change(), 
ligne 19 à EXECUTE instruction SQL « 
UPDATE tww_od.wastewater_node 
SET obj_id = NEW.obj_id , 
_function_hierarchic = NEW._function_hierarchic , 
_status = NEW._status , 
_usage_current = NEW._usage_current , 
backflow_level_current = NEW.backflow_level_current , 
bottom_level = NEW.bottom_level , 
elevation_accuracy = NEW.elevation_accuracy , 
fk_hydr_geometry = NEW.fk_hydr_geometry , 
function_node_amelioration = NEW.function_node_amelioration , 
situation3d_geometry = NEW.situation3d_geometry , 
wwtp_number = NEW.wwtp_number 
WHERE obj_id = OLD.obj_id » fonction PL/pgSQL tww_app.ft_vw_wastewater_node_update(), ligne 12 à instruction SQL
Couche vw_wastewater_node: Erreur PostGIS lors de la modification d'attribut : 
ERREUR: champ numérique en dehors des limites 
DETAIL: Un champ de précision 6 et d'échelle 3 doit être arrondi à une valeur absolue inférieure à 10^3. 
CONTEXT: instruction SQL « 
UPDATE tww_od.wastewater_structure ws 
SET _depth = depth 
FROM ( SELECT WS.obj_id, 
    CO.level - COALESCE(MIN(NO.bottom_level), 
    MIN(RP.level)) as depth 
    FROM tww_od.wastewater_structure WS 
    LEFT JOIN tww_od.cover CO on WS.fk_main_cover = CO.obj_id 
    LEFT JOIN tww_od.wastewater_networkelement NE ON NE.fk_wastewater_structure = WS.obj_id 
    RIGHT JOIN tww_od.wastewater_node NO on NO.obj_id = NE.obj_id 
    LEFT JOIN tww_od.reach_point RP ON RP.fk_wastewater_networkelement = NE.obj_id 
    WHERE _all OR WS.obj_id = _obj_id 
    GROUP BY WS.obj_id, CO.level ) ws_depths where ws.obj_id = ws_depths.obj_id 
» 
fonction PL/pgSQL tww_app.update_depth(text,boolean), ligne 6 à instruction SQL expression SQL « tww_app.update_depth(affected_sp.fk_wastewater_structure) » fonction PL/pgSQL tww_app.on_wasterwaternode_change(), ligne 19 à 
EXECUTE instruction SQL « 
UPDATE tww_od.wastewater_node 
SET obj_id = NEW.obj_id , 
_function_hierarchic = NEW._function_hierarchic ,
_status = NEW._status , 
_usage_current = NEW._usage_current , 
backflow_level_current = NEW.backflow_level_current , 
bottom_level = NEW.bottom_level , 
elevation_accuracy = NEW.elevation_accuracy , 
fk_hydr_geometry = NEW.fk_hydr_geometry , 
function_node_amelioration = NEW.function_node_amelioration , 
situation3d_geometry = NEW.situation3d_geometry , 
wwtp_number = NEW.wwtp_number 
WHERE obj_id = OLD.obj_id 
» fonction PL/pgSQL tww_app.ft_vw_wastewater_node_update(), ligne 12 à instruction SQL 

To Reproduce Exact steps to reproduce the behavior:

  1. Go to a wastewater structure
  2. Open form
  3. Go to the node tab
  4. Add an altitude

Expected behavior No error message is prompted.

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.

cymed commented 1 month ago

What values did you enter? tww_app.update_depth was not touched for a long time. The error you got suggests that the depth was greater than 1 km

urskaufmann commented 1 month ago

I think it's this 999.99-limit. See also QGEP-Issue 748

ponceta commented 1 month ago

This will be problematic for Zermatt!

cymed commented 1 month ago

The problem is not the altitude, the problem is the depth of the manhole if the bottom_level is zero

ponceta commented 1 month ago

Ok so we need to rework the _depth calculation when bottom_level = 0 or is NULL