From 5a35cccaca9060b29eb0f004469b1d5420fae3e1 Mon Sep 17 00:00:00 2001 From: "xtorret@bgeo.es" Date: Sun, 18 Aug 2024 23:27:07 +0200 Subject: [PATCH] clean code (various fct & trg): Remove nodetype_id, connectype_id and cat_arctype_id from vu_* and v_edit_ tables --- ...s_gw_fct_anl_node_topological_consistency.sql | 16 ++++++++-------- .../ws_gw_fct_graphanalytics_mapzones_config.sql | 2 +- ws/fct/ws_gw_fct_pg2epa_fill_data.sql | 2 +- ws/ftrg/ws_gw_trg_arc_node_values.sql | 4 ++-- ws/ftrg/ws_gw_trg_arc_noderotation_update.sql | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ws/fct/ws_gw_fct_anl_node_topological_consistency.sql b/ws/fct/ws_gw_fct_anl_node_topological_consistency.sql index 3c5190c526..824d5d7bcc 100644 --- a/ws/fct/ws_gw_fct_anl_node_topological_consistency.sql +++ b/ws/fct/ws_gw_fct_anl_node_topological_consistency.sql @@ -65,7 +65,7 @@ BEGIN SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id + JOIN cat_feature_node ON node_type=id WHERE num_arcs=4 AND node_id IN ('||v_array ||') GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 4 @@ -73,7 +73,7 @@ BEGIN SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id + JOIN cat_feature_node ON node_type=id WHERE num_arcs=3 AND node_id IN ('||v_array ||') GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 3 @@ -81,7 +81,7 @@ BEGIN SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id + JOIN cat_feature_node ON node_type=id WHERE num_arcs=2 AND node_id IN ('||v_array ||') GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 2 @@ -89,7 +89,7 @@ BEGIN SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id + JOIN cat_feature_node ON node_type=id WHERE num_arcs=1 AND node_id IN ('||v_array ||') GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 1;'; @@ -98,28 +98,28 @@ BEGIN SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id WHERE num_arcs=4 + JOIN cat_feature_node ON node_type=id WHERE num_arcs=4 GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 4 UNION SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id WHERE num_arcs=3 + JOIN cat_feature_node ON node_type=id WHERE num_arcs=3 GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 3 UNION SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id WHERE num_arcs=2 + JOIN cat_feature_node ON node_type=id WHERE num_arcs=2 GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 2 UNION SELECT node_id, nodecat_id, '||v_worklayer||'.state, COUNT(*), '||v_worklayer||'.expl_id, 108, '||v_worklayer||'.the_geom FROM '||v_worklayer||' JOIN v_edit_arc ON v_edit_arc.node_1 = '||v_worklayer||'.node_id OR v_edit_arc.node_2 = '||v_worklayer||'.node_id - JOIN cat_feature_node ON nodetype_id=id WHERE num_arcs=1 + JOIN cat_feature_node ON node_type=id WHERE num_arcs=1 GROUP BY '||v_worklayer||'.node_id, nodecat_id, '||v_worklayer||'.state, '||v_worklayer||'.expl_id, '||v_worklayer||'.the_geom HAVING COUNT(*) != 1;'; END IF; diff --git a/ws/fct/ws_gw_fct_graphanalytics_mapzones_config.sql b/ws/fct/ws_gw_fct_graphanalytics_mapzones_config.sql index c828e963d6..fd9fbc8586 100644 --- a/ws/fct/ws_gw_fct_graphanalytics_mapzones_config.sql +++ b/ws/fct/ws_gw_fct_graphanalytics_mapzones_config.sql @@ -108,7 +108,7 @@ BEGIN VALUES (249, 1, concat('Delimitier node type: ', v_mapzone_nodetype,'.')); - FOR rec IN EXECUTE '(SELECT node_id::text, expl_id FROM v_edit_node WHERE nodetype_id IN (SELECT id FROM cat_feature_node WHERE graph_delimiter IN '||v_graph_class_list||'))' + FOR rec IN EXECUTE '(SELECT node_id::text, expl_id FROM v_edit_node WHERE node_type IN (SELECT id FROM cat_feature_node WHERE graph_delimiter IN '||v_graph_class_list||'))' LOOP --find defined sector value of node EXECUTE 'SELECT '||v_mapzonefield||' FROM node WHERE node_id = '||rec.node_id||'::text' diff --git a/ws/fct/ws_gw_fct_pg2epa_fill_data.sql b/ws/fct/ws_gw_fct_pg2epa_fill_data.sql index 2bfb31306c..434076881d 100644 --- a/ws/fct/ws_gw_fct_pg2epa_fill_data.sql +++ b/ws/fct/ws_gw_fct_pg2epa_fill_data.sql @@ -135,7 +135,7 @@ BEGIN EXECUTE 'INSERT INTO temp_t_arc (arc_id, node_1, node_2, arc_type, arccat_id, epa_type, sector_id, state, state_type, annotation, roughness, length, diameter, the_geom, expl_id, dma_id, presszone_id, dqa_id, minsector_id, age) SELECT - v_edit_arc.arc_id, node_1, node_2, v_edit_arc.cat_arctype_id, arccat_id, epa_type, v_edit_arc.sector_id, v_edit_arc.state, v_edit_arc.state_type, v_edit_arc.annotation, + v_edit_arc.arc_id, node_1, node_2, v_edit_arc.arc_type, arccat_id, epa_type, v_edit_arc.sector_id, v_edit_arc.state, v_edit_arc.state_type, v_edit_arc.annotation, CASE WHEN custom_roughness IS NOT NULL THEN custom_roughness ELSE roughness END AS roughness, (CASE WHEN v_edit_arc.custom_length IS NOT NULL THEN custom_length ELSE gis_length END), (CASE WHEN inp_pipe.custom_dint IS NOT NULL THEN custom_dint ELSE dint END), -- diameter is child value but in order to make simple the query getting values from v_edit_arc (dint)... diff --git a/ws/ftrg/ws_gw_trg_arc_node_values.sql b/ws/ftrg/ws_gw_trg_arc_node_values.sql index fb5d3c8156..bc51e0615e 100644 --- a/ws/ftrg/ws_gw_trg_arc_node_values.sql +++ b/ws/ftrg/ws_gw_trg_arc_node_values.sql @@ -19,11 +19,11 @@ BEGIN IF (SELECT value::boolean FROM config_param_user WHERE parameter = 'edit_disable_update_nodevalues' and cur_user = current_user) IS NOT FALSE THEN - UPDATE arc a SET nodetype_1 = nodetype_id ,elevation1 = n.elevation, depth1 = n.depth, staticpress1 = n.staticpressure + UPDATE arc a SET nodetype_1 = node_type ,elevation1 = n.elevation, depth1 = n.depth, staticpress1 = n.staticpressure FROM vu_node n WHERE a.arc_id = NEW.arc_id AND node_id = node_1; - UPDATE arc a SET nodetype_2 = nodetype_id ,elevation2 = n.elevation, depth2 = n.depth, staticpress2 = n.staticpressure + UPDATE arc a SET nodetype_2 = node_type ,elevation2 = n.elevation, depth2 = n.depth, staticpress2 = n.staticpressure FROM vu_node n WHERE a.arc_id = NEW.arc_id AND node_id = node_2; diff --git a/ws/ftrg/ws_gw_trg_arc_noderotation_update.sql b/ws/ftrg/ws_gw_trg_arc_noderotation_update.sql index ae0e0c8f6a..7ee9279bfd 100644 --- a/ws/ftrg/ws_gw_trg_arc_noderotation_update.sql +++ b/ws/ftrg/ws_gw_trg_arc_noderotation_update.sql @@ -32,7 +32,7 @@ BEGIN FOR rec_node IN SELECT * FROM v_edit_node WHERE NEW.node_1 = node_id OR NEW.node_2 = node_id LOOP - SELECT choose_hemisphere INTO hemisphere_rotation_bool FROM v_edit_node JOIN cat_feature_node ON rec_node.nodetype_id=id; + SELECT choose_hemisphere INTO hemisphere_rotation_bool FROM v_edit_node JOIN cat_feature_node ON rec_node.node_type=id; SELECT hemisphere INTO hemisphere_rotation_aux FROM v_edit_node WHERE node_id=rec_node.node_id; -- init variables @@ -90,7 +90,7 @@ BEGIN FOR rec_node IN SELECT * FROM v_edit_node WHERE NEW.node_1 = node_id OR NEW.node_2 = node_id LOOP - SELECT choose_hemisphere INTO hemisphere_rotation_bool FROM v_edit_node JOIN cat_feature_node ON rec_node.nodetype_id=id; + SELECT choose_hemisphere INTO hemisphere_rotation_bool FROM v_edit_node JOIN cat_feature_node ON rec_node.node_type=id; SELECT hemisphere INTO hemisphere_rotation_aux FROM v_edit_node WHERE node_id=rec_node.node_id; -- init variables @@ -147,7 +147,7 @@ BEGIN FOR rec_node IN SELECT node_id,nodetype_id, the_geom FROM v_edit_node WHERE OLD.node_1 = node_id OR OLD.node_2 = node_id LOOP - SELECT choose_hemisphere INTO hemisphere_rotation_bool FROM v_edit_node JOIN cat_feature_node ON rec_node.nodetype_id=id; + SELECT choose_hemisphere INTO hemisphere_rotation_bool FROM v_edit_node JOIN cat_feature_node ON rec_node.node_type=id; SELECT hemisphere INTO hemisphere_rotation_aux FROM v_edit_node WHERE node_id=rec_node.node_id; -- init variables