Skip to content

Commit

Permalink
clean code (various fct & trg): Remove nodetype_id, connectype_id and…
Browse files Browse the repository at this point in the history
… cat_arctype_id from vu_* and v_edit_ tables
  • Loading branch information
xtorret committed Aug 18, 2024
1 parent a849b6e commit 5a35ccc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions ws/fct/ws_gw_fct_anl_node_topological_consistency.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,31 @@ 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
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
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
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
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
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
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;';
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ws/fct/ws_gw_fct_graphanalytics_mapzones_config.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion ws/fct/ws_gw_fct_pg2epa_fill_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)...
Expand Down
4 changes: 2 additions & 2 deletions ws/ftrg/ws_gw_trg_arc_node_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions ws/ftrg/ws_gw_trg_arc_noderotation_update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5a35ccc

Please sign in to comment.