Skip to content

Commit 86004f1

Browse files
committed
fix(pg2epa_nodarc_export): Export as JUNCTION those valves and pumps with epa_type = 'JUNCTION'
1 parent 5911782 commit 86004f1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

ws/fct/ws_gw_fct_pg2epa_nod2arc.sql

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,26 @@ BEGIN
6262
UNION ALL SELECT node_2 FROM v_edit_arc) a using (node_id) group by n.node_id';
6363

6464
-- query text for mandatory node2arcs
65-
v_querytext = 'SELECT a.*, man_valve.to_arc FROM temp_t_node a JOIN man_valve ON a.node_id=man_valve.node_id WHERE to_arc is not null
65+
v_querytext = 'SELECT a.*, v.to_arc FROM temp_t_node a JOIN man_valve v ON a.node_id=v.node_id JOIN inp_valve i ON i.node_id = v.node_id WHERE to_arc is not null
6666
UNION
67-
SELECT a.*, man_pump.to_arc FROM temp_t_node a JOIN man_pump ON a.node_id=man_pump.node_id WHERE to_arc is not null';
67+
SELECT a.*, m.to_arc FROM temp_t_node a JOIN man_pump m ON a.node_id=m.node_id JOIN inp_pump i ON i.node_id=m.node_id WHERE to_arc is not null';
6868

6969

70-
v_querytext = concat (' INSERT INTO temp_anl_node (num_arcs, arc_id, node_id, elevation, elev, nodecat_id, sector_id, state, state_type, descript, arc_distance, the_geom, fid, cur_user, dma_id, presszone_id, dqa_id, minsector_id)
71-
SELECT c.numarcs, to_arc, b.node_id, elevation, elev, nodecat_id, sector_id, state, state_type, ''MANDATORY'', demand, the_geom, 124, current_user, dma_id, presszone_id, dqa_id, minsector_id
70+
v_querytext = concat (' INSERT INTO temp_anl_node (num_arcs, arc_id, node_id, elevation, elev, nodecat_id, sector_id, state, state_type, descript, arc_distance, the_geom, fid, cur_user,
71+
dma_id, presszone_id, dqa_id, minsector_id)
72+
SELECT c.numarcs, to_arc, b.node_id, elevation, elev, nodecat_id, sector_id, state, state_type, ''MANDATORY'', demand, the_geom, 124, current_user, dma_id,
73+
presszone_id, dqa_id, minsector_id
7274
FROM ( ',v_querytext, ' ) b JOIN ( ',v_query_number,' ) c USING (node_id)');
7375
EXECUTE v_querytext;
7476

7577
-- query text for non-mandatory node2arcs
7678
IF p_only_mandatory_nodarc IS FALSE THEN
77-
v_querytext = 'SELECT a.*, s.to_arc FROM temp_t_node a JOIN man_valve s ON a.node_id=s.node_id WHERE s.to_arc IS NULL';
79+
v_querytext = 'SELECT a.*, s.to_arc FROM temp_t_node a JOIN man_valve s ON a.node_id=s.node_id JOIN inp_shortpipe i ON i.node_id = s.node_id WHERE s.to_arc IS NULL';
7880

79-
v_querytext = concat (' INSERT INTO temp_anl_node (num_arcs, arc_id, node_id, elevation, elev, nodecat_id, sector_id, state, state_type, descript, arc_distance, the_geom, fid, cur_user, dma_id, presszone_id, dqa_id, minsector_id)
80-
SELECT c.numarcs, to_arc, b.node_id, elevation, elev, nodecat_id, sector_id, state, state_type, ''NOT-MANDATORY'', demand, the_geom, 124, current_user, dma_id, presszone_id, dqa_id, minsector_id
81+
v_querytext = concat (' INSERT INTO temp_anl_node (num_arcs, arc_id, node_id, elevation, elev, nodecat_id, sector_id, state, state_type, descript, arc_distance,
82+
the_geom, fid, cur_user, dma_id, presszone_id, dqa_id, minsector_id)
83+
SELECT c.numarcs, to_arc, b.node_id, elevation, elev, nodecat_id, sector_id, state, state_type, ''NOT-MANDATORY'', demand, the_geom, 124,
84+
current_user, dma_id, presszone_id, dqa_id, minsector_id
8185
FROM ( ',v_querytext, ' ) b JOIN ( ',v_query_number,' ) c USING (node_id)');
8286
EXECUTE v_querytext;
8387
END IF;

0 commit comments

Comments
 (0)