qwat / qwat-data-model

TEKSI Water module (project QWAT) - PostgreSQL / postgis Datamodel
https://www.teksi.ch
23 stars 24 forks source link

Fix orientation of element part when updating pipe or element part #349

Closed benoitblanc closed 1 year ago

benoitblanc commented 2 years ago

Description

When user wants to connect an element part to a pipe, orientation of the element is wrong, fixing angle to 0 or some wrong value.

Before

qwat

After

demo_qwat_fix_orientation

To do so, I fixed the node taken into account when updating pipe in trigger (NEW instead of OLD).

Then, for the element part update, I need to call a function in auto-generated trigger qwat_od.ft_element_part_update. So I have created a custom_update in ordinary_data/views/inheritance/od_all_inheritance.py and I wanted to handle it in ordinary_data/views/inheritance/pg_inheritance_view_recursive.py in sql_join_update_trigger method (as there is the same thing with custom_delete). But I have an error when I try to generate views :

/QWAT/data-model/ordinary_data/views/insert_views.sh: ligne 15: /usr/bin/psql: Liste d'arguments trop longue

So I am wondering how I can add an argument, something is missing but I can't find what... @3nids I need some help to understand how to add custom code in auto-generated triggers.

Thanks

benoitblanc commented 2 years ago

I am not sure for the custom function. Sylvain originally wrote the Python code, and I am not really familiar with the code.

It was the right way to add custom code in generated trigger, but I had two ;; generated. One in od_all_inheritance.py and one in fn_element_part_set_orientation.sql :facepalm:

ponceta commented 1 year ago

Since CI is functionnal again, I would try to get this fixed if possible.

@kandre can you follow this?

ponceta commented 1 year ago

@benoitblanc we need a delta and a test here, could you provide it?

Test should be based on similar testing from @sylvainbeo mentionned by @3nids

benoitblanc commented 1 year ago

@ponceta I have rebased this branch on master, added deltas and added one test to update orientation by moving a node of a pipe.

ponceta commented 1 year ago

Thank you @benoitblanc this is great!