Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add (option) to run query tww_update_maincover after import #75

Closed
sjib opened this issue Jan 15, 2024 · 8 comments
Closed

Add (option) to run query tww_update_maincover after import #75

sjib opened this issue Jan 15, 2024 · 8 comments
Labels
INTERLIS About INTERLIS exchange format (import / export) plugin Concerns the wastewater plugin

Comments

@sjib
Copy link
Contributor

sjib commented Jan 15, 2024

When importing INTERLIS data you cannot select objects on the layer vw_tww_wastewater_structure and symbols are not displayed correctly:

import_test-dataset-DSS xtf_new_version_ok

The following query needs to be applied to set a main_cover:

UPDATE tww_od.wastewater_structure WS SET fk_main_cover = structure_cover.co_obj_id FROM ( SELECT WS.obj_id AS obj_id, min(CO.obj_id) AS co_obj_id FROM tww_od.wastewater_structure WS LEFT JOIN tww_od.structure_part SP ON SP.fk_wastewater_structure = WS.obj_id LEFT JOIN tww_od.cover CO ON SP.obj_id = CO.obj_id GROUP BY WS.obj_id ) AS structure_cover WHERE structure_cover.obj_id = WS.obj_id;

import_test-dataset-DSS xtf_new_version_maincover_applied

@ponceta To discuss in technial group tomorrow how to add this. Also discuss if query update_mainnode is also necessary or not.

@domi4484
Copy link
Contributor

domi4484 commented Jan 15, 2024

@sjib let me know if and which queries need to be added to complete the import

Would this be an option or something that can be run always?

@sjib
Copy link
Contributor Author

sjib commented Jan 16, 2024

The new datamodel has a fk_main_cover, so we should not overwrite it if it is existing.
But for display the TEKSI attribut fk_main_node is important - so rather run this query:

UPDATE tww_od.wastewater_structure WS SET fk_main_wastewater_node = structure_node.wn_obj_id FROM ( SELECT WS.obj_id AS obj_id, min(WN.obj_id) AS wn_obj_id FROM tww_od.wastewater_structure WS LEFT JOIN tww_od.wastewater_networkelement NE ON NE.fk_wastewater_structure = WS.obj_id LEFT JOIN tww_od.wastewater_node WN ON NE.obj_id = WN.obj_id GROUP BY WS.obj_id ) AS structure_node WHERE structure_node.obj_id = WS.obj_id;

To discuss - do we want to chose the node with the lowest obj_id or the lowest level instead?

@urskaufmann
Copy link
Contributor

I have reimported again: first got the map with the node-crosses (as shown above).
Then just run the main_node_update.sql -> vw_tww_wastewater_structure symbols are visible, the view works.

But: in the vw_tww_wastewater_structure form, tab "maincover/mainnode", there is no data in the cover-window. Well, I can edit the covers in the "covers" tab - except when digitizing a new wastewater_structure. Thats the reason, why main_cover_update should run after import (only for wastewater_structure, that have NULL as fk_main_cover.

I have also just run the main_cover_update after importing. The result was, that there is no node-data in vw_tww_wastewater_structure, and because there is a not NULL constraint in attribut wn_obj_id, I can not save any changes in the attribut form. So we have to run both updates - main node and main cover.

@cymed
Copy link
Contributor

cymed commented Jan 17, 2024

I have reimported again: first got the map with the node-crosses (as shown above). Then just run the main_node_update.sql -> vw_tww_wastewater_structure symbols are visible, the view works.

But: in the vw_tww_wastewater_structure form, tab "maincover/mainnode", there is no data in the cover-window. Well, I can edit the covers in the "covers" tab - except when digitizing a new wastewater_structure. Thats the reason, why main_cover_update should run after import (only for wastewater_structure, that have NULL as fk_main_cover.

I have also just run the main_cover_update after importing. The result was, that there is no node-data in vw_tww_wastewater_structure, and because there is a not NULL constraint in attribut wn_obj_id, I can not save any changes in the attribut form. So we have to run both updates - main node and main cover.

#36 inserts a new cover on update if there was none before and at least one attribute is used. So as soon as we merge this, the cover problematic is gone.
Also #58 defines the new cover as the main cover if there is no prior cover

@sjib
Copy link
Contributor Author

sjib commented Jan 17, 2024

Thats the reason, why main_cover_update should run after import (only for wastewater_structure, that have NULL as fk_main_cover.

Here the adjusted query for main_node with WHERE fk_main_wastewater_node IS NULL

UPDATE tww_od.wastewater_structure WS
SET fk_main_wastewater_node = structure_node.wn_obj_id
FROM (
  SELECT WS.obj_id AS obj_id, min(WN.obj_id) AS wn_obj_id, fk_main_wastewater_node
  FROM tww_od.wastewater_structure WS
  LEFT JOIN tww_od.wastewater_networkelement NE ON NE.fk_wastewater_structure = WS.obj_id
  LEFT JOIN tww_od.wastewater_node WN ON NE.obj_id = WN.obj_id
  WHERE fk_main_wastewater_node IS NULL 
  GROUP BY WS.obj_id
  ) AS structure_node
WHERE structure_node.obj_id = WS.obj_id;

@sjib
Copy link
Contributor Author

sjib commented Jan 17, 2024

And for main_cover:

    SET fk_main_cover = structure_cover.co_obj_id FROM ( 
	   SELECT WS.obj_id AS obj_id, min(CO.obj_id) AS co_obj_id, fk_main_cover 
	   FROM tww_od.wastewater_structure WS 
	   LEFT JOIN tww_od.structure_part SP ON SP.fk_wastewater_structure = WS.obj_id 
	   LEFT JOIN tww_od.cover CO ON SP.obj_id = CO.obj_id
	   WHERE fk_main_cover IS NULL 
	   GROUP BY WS.obj_id 
    ) AS structure_cover 
WHERE structure_cover.obj_id = WS.obj_id;

@domi4484 Please check if IS NULL is placed correctly
We can decide on Friday whether we take the option and improvements from @cymed or go with these first

@3nids 3nids added plugin Concerns the wastewater plugin INTERLIS About INTERLIS exchange format (import / export) labels Jan 19, 2024
@sjib
Copy link
Contributor Author

sjib commented Jan 19, 2024

@3nids
Copy link
Contributor

3nids commented Jan 23, 2024

should be fixed in last plugin demo, please re-open if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INTERLIS About INTERLIS exchange format (import / export) plugin Concerns the wastewater plugin
Projects
None yet
Development

No branches or pull requests

5 participants