Skip to content

Commit

Permalink
Bug fix exporting culvert, kentry, kexit, kavg, flap and seepage on c…
Browse files Browse the repository at this point in the history
…onduits (UD)
  • Loading branch information
xtorret committed Oct 22, 2021
1 parent 07db500 commit c4d1979
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ud/fct/ud_gw_fct_pg2epa_fill_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ BEGIN

-- Insert on arc rpt_inp table
INSERT INTO temp_arc
(result_id, arc_id, node_1, node_2, elevmax1, elevmax2, arc_type, arccat_id, epa_type, sector_id, state, state_type, annotation, length, n, expl_id, the_geom, q0, qmax, barrels, slope)
(result_id, arc_id, node_1, node_2, elevmax1, elevmax2, arc_type, arccat_id, epa_type, sector_id, state, state_type, annotation, length, n, expl_id, the_geom, q0, qmax, barrels, slope,
culvert, kentry, kexit, kavg, flap, seepage)
SELECT
result_id_var,
a.arc_id, node_1, node_2, a.sys_elev1, a.sys_elev2, a.arc_type, arccat_id, epa_type, a.sector_id, a.state,
Expand All @@ -121,7 +122,8 @@ BEGIN
q0,
qmax,
barrels,
slope
slope,
culvert, kentry, kexit, kavg, flap, seepage
FROM selector_sector, v_arc a
LEFT JOIN value_state_type ON id=state_type
LEFT JOIN cat_mat_arc ON matcat_id = cat_mat_arc.id
Expand Down
4 changes: 2 additions & 2 deletions ud/fct/ud_gw_fct_pg2epa_main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ BEGIN
UPDATE temp_arc SET result_id = v_result;
UPDATE temp_node SET result_id = v_result;
INSERT INTO rpt_inp_arc (result_id, arc_id, flw_code, node_1, node_2, elevmax1, elevmax2, arc_type, arccat_id, epa_type, sector_id, state, state_type, annotation,
length, n, the_geom, expl_id, minorloss, addparam, arcparent, q0, qmax, barrels, slope)
length, n, the_geom, expl_id, minorloss, addparam, arcparent, q0, qmax, barrels, slope, culvert, kentry, kexit, kavg, flap, seepage)
SELECT
result_id, arc_id, flw_code, node_1, node_2, elevmax1, elevmax2, arc_type, arccat_id, epa_type, sector_id, state, state_type, annotation,
length, n, the_geom, expl_id, minorloss, addparam, arcparent, q0, qmax, barrels, slope
length, n, the_geom, expl_id, minorloss, addparam, arcparent, q0, qmax, barrels, slope, culvert, kentry, kexit, kavg, flap, seepage
FROM temp_arc;
INSERT INTO rpt_inp_node (result_id, node_id, flw_code, top_elev, ymax, elev, node_type, nodecat_id,
epa_type, sector_id, state, state_type, annotation, y0, ysur, apond, the_geom, expl_id, addparam, parent, arcposition, fusioned_node)
Expand Down
23 changes: 23 additions & 0 deletions updates/35/35016/ud/ddlview.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
This file is part of Giswater 3
The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This version of Giswater is provided by Giswater Association
*/


SET search_path = SCHEMA_NAME, public, pg_catalog;


--2021/10/21

DROP VIEW IF EXISTS vi_losses;
CREATE OR REPLACE VIEW vi_losses AS
SELECT arc_id,
CASE WHEN kentry IS NOT NULL THEN kentry ELSE 0 END AS kentry,
CASE WHEN kexit IS NOT NULL THEN kexit ELSE 0 END AS kexit,
CASE WHEN kavg IS NOT NULL THEN kavg ELSE 0 END AS kavg,
CASE WHEN flap IS NOT NULL THEN flap ELSE 'NO' END AS flap,
seepage
FROM temp_arc
WHERE kentry > 0::numeric OR kexit > 0::numeric OR kavg > 0::numeric
OR flap::text = 'YES'::text OR seepage is not null;

0 comments on commit c4d1979

Please sign in to comment.