diff --git a/delta/delta_1.6.1_add_ii_to_swmm_outfalls b/delta/delta_1.6.1_add_ii_to_swmm_outfalls new file mode 100644 index 00000000..16199ac9 --- /dev/null +++ b/delta/delta_1.6.1_add_ii_to_swmm_outfalls @@ -0,0 +1,4 @@ +-------- +-- View for the swmm module class outfalls now includes infiltration installations +-------- +SELECT 1; diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 992be3a3..1b079fac 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -15,11 +15,11 @@ SELECT CONCAT_WS(',', 'manhole', mf.value_en) as tag, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id @@ -29,8 +29,10 @@ LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::te LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id LEFT JOIN qgep_od.cover co on ws.fk_main_cover = co.obj_id LEFT JOIN qgep_vl.manhole_function mf on ma.function = mf.code +LEFT JOIN qgep_vl.wastewater_structure_status ws_st on ws_st.code=ws.status +LEFT JOIN qgep_vl.channel_function_hierarchic ch_fh on ch_fh.code=ws._function_hierarchic WHERE wn.obj_id IS NOT NULL -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) UNION @@ -43,14 +45,14 @@ SELECT NULL::float as SurchargeDepth, NULL::float as PondedArea, ws.identifier::text as description, - CONCAT_WS(',','special_structure', ssf.value_en) as tag, + CONCAT_WS(',','special_structure', ss_fu.value_en) as tag, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id @@ -59,10 +61,12 @@ LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ss.obj_id::text LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id LEFT JOIN qgep_od.cover co on ws.fk_main_cover = co.obj_id -LEFT JOIN qgep_vl.special_structure_function ssf on ss.function = ssf.code +LEFT JOIN qgep_vl.special_structure_function ss_fu on ss_fu.code=ss.function +LEFT JOIN qgep_vl.wastewater_structure_status ws_st on ws_st.code=ws.status +LEFT JOIN qgep_vl.channel_function_hierarchic ch_fh on ch_fh.code=ws._function_hierarchic WHERE wn.obj_id IS NOT NULL -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) -AND function NOT IN ( -- must be the same list in vw_swmm_storages +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND ss_fu.vsacode NOT IN ( -- must be the same list in vw_swmm_storages 6397, --"pit_without_drain" -- 245, --"drop_structure" 6398, --"hydrolizing_tank" @@ -109,11 +113,11 @@ SELECT 'junction without structure' as tag, coalesce(from_wn.situation_geometry, ST_StartPoint(re.progression_geometry)) as geom, CASE - WHEN ws.status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, coalesce(from_wn.obj_id, re.obj_id) as obj_id @@ -126,8 +130,10 @@ LEFT JOIN qgep_od.channel ch on ch.obj_id::text = ws.obj_id::text -- Get wastewater structure linked to the from node LEFT JOIN qgep_od.wastewater_networkelement we ON from_wn.obj_id = we.obj_id LEFT JOIN qgep_od.wastewater_structure ws_node ON we.fk_wastewater_structure::text = ws_node.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st on ws_st.code=ws.status +LEFT JOIN qgep_vl.channel_function_hierarchic ch_fh on ch_fh.code=ch.function_hierarchic -- select only operationals and "planned" -WHERE ws.status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) and ws_node is null UNION @@ -143,11 +149,11 @@ SELECT 'junction without structure' as tag, coalesce(to_wn.situation_geometry, ST_EndPoint(re.progression_geometry)) as geom, CASE - WHEN ws.status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, coalesce(to_wn.obj_id, re.obj_id) as obj_id @@ -160,6 +166,8 @@ LEFT JOIN qgep_od.channel ch on ch.obj_id::text = ws.obj_id::text -- Get wastewater structure linked to the to node LEFT JOIN qgep_od.wastewater_networkelement we ON to_wn.obj_id = we.obj_id LEFT JOIN qgep_od.wastewater_structure ws_node ON we.fk_wastewater_structure::text = ws_node.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st on ws_st.code=ws.status +LEFT JOIN qgep_vl.channel_function_hierarchic ch_fh on ch_fh.code=ch.function_hierarchic -- select only operationals and "planned" -WHERE ws.status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) and ws_node is null; diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 0fe618dd..c82a89e9 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -52,17 +52,17 @@ SELECT ELSE 'Default value 0.01 is used as roughness' END, CASE - WHEN pp.profile_type = 3350 THEN + WHEN vl_pp.vsacode = 3350 THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': circular profile with default value of 0.1m as clear_height') ELSE NULL END - WHEN pp.profile_type = 3351 THEN + WHEN vl_pp.vsacode = 3351 THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': egg profile with default value of 0.1m as clear_height') ELSE NULL END - WHEN pp.profile_type = 3352 THEN + WHEN vl_pp.vsacode = 3352 THEN CASE WHEN pp.height_width_ratio IS NOT NULL THEN CASE @@ -75,7 +75,7 @@ SELECT ELSE concat('Reach', re.obj_id,': arch profile with default value of 1 as height_width_ratio and with known clear_height value') END END - WHEN pp.profile_type = 3353 THEN + WHEN vl_pp.vsacode = 3353 THEN CASE WHEN pp.height_width_ratio IS NOT NULL THEN CASE @@ -88,7 +88,7 @@ SELECT ELSE concat('Reach', re.obj_id,': rectangular profile with default value of 1 as height_width_ratio and with known clear_height value') END END - WHEN pp.profile_type = 3354 THEN + WHEN vl_pp.vsacode = 3354 THEN CASE WHEN pp.height_width_ratio IS NOT NULL THEN CASE @@ -101,7 +101,7 @@ SELECT ELSE concat('Reach', re.obj_id,': parabolic profile with default value of 1 as height_width_ratio, with known clear_height value and no code value') END END - WHEN pp.profile_type = 3355 THEN concat('Reach', re.obj_id,': custom profile to be defined in SWMM') + WHEN vl_pp.vsacode = 3355 THEN concat('Reach', re.obj_id,': custom profile to be defined in SWMM') END, CASE WHEN to_wn.obj_id IS NULL THEN 'Blind connection, the destination node must be edited' @@ -109,19 +109,20 @@ SELECT ELSE NULL END ) as description, - cfh.value_en as tag, + cfhy.value_en as tag, ST_CurveToLine(st_force3d(progression_geometry))::geometry(LineStringZ, %(SRID)s) as geom, CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, re.obj_id as obj_id FROM qgep_od.reach as re LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile +LEFT JOIN qgep_vl.pipe_profile_profile_type vl_pp on pp.profile_type = vl_pp.code LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure LEFT JOIN qgep_od.reach_point rp_from ON rp_from.obj_id::text = re.fk_reach_point_from::text @@ -129,7 +130,8 @@ LEFT JOIN qgep_od.reach_point rp_to ON rp_to.obj_id::text = re.fk_reach_point_to LEFT JOIN qgep_od.wastewater_node from_wn on from_wn.obj_id = rp_from.fk_wastewater_networkelement LEFT JOIN qgep_od.wastewater_node to_wn on to_wn.obj_id = rp_to.fk_wastewater_networkelement LEFT JOIN qgep_od.channel ch on ch.obj_id::text = ws.obj_id::text -LEFT JOIN qgep_vl.channel_function_hydraulic cfh on cfh.code = ch.function_hydraulic +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi on cfhi.code = ch.function_hierarchic +LEFT JOIN qgep_vl.channel_function_hydraulic cfhy on cfhy.code = ch.function_hydraulic -- select only operationals and "planned" WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); -- 6526 "other.calculation_alternative" diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index dfeecbe0..310bb178 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -15,22 +15,24 @@ SELECT 0 as PondedArea, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.manhole ma LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ma.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.cover co on ws.fk_main_cover = co.obj_id LEFT JOIN qgep_vl.manhole_function mf on ma.function = mf.code -WHERE function = 4798 -- separating_structure -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE mf.vsacode = 4798 -- separating_structure +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -46,19 +48,21 @@ SELECT 0 as PondedArea, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.special_structure ss LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ss.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.cover co on ws.fk_main_cover = co.obj_id LEFT JOIN qgep_vl.special_structure_function ssf on ss.function = ssf.code -WHERE function = 4799 -- separating_structure -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); +WHERE ssf.vsacode = 4799 -- separating_structure +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/07_vw_swmm_losses.sql b/swmm_views/07_vw_swmm_losses.sql index 07826969..e10079a0 100644 --- a/swmm_views/07_vw_swmm_losses.sql +++ b/swmm_views/07_vw_swmm_losses.sql @@ -30,5 +30,6 @@ LEFT JOIN qgep_od.reach_point rp_from ON rp_from.obj_id::text = re.fk_reach_poin LEFT JOIN qgep_od.wastewater_node from_wn on from_wn.obj_id = rp_from.fk_wastewater_networkelement LEFT JOIN qgep_od.throttle_shut_off_unit ts ON ts.fk_wastewater_node = from_wn.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) ; -- wastewater node of the downstream wastewater node diff --git a/swmm_views/08_vw_swmm_outfalls.sql b/swmm_views/08_vw_swmm_outfalls.sql index 9861eb63..b0dc5feb 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -14,18 +14,50 @@ SELECT dp.obj_id::varchar as tag, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.discharge_point as dp LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = dp.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id WHERE wn.obj_id IS NOT NULL -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) + +UNION + +SELECT + wn.obj_id as Name, + coalesce(wn.bottom_level,0) as InvertElev, + 'FREE'::varchar as Type, + NULL as StageData, + 'NO'::varchar as tide_gate, + NULL::varchar as RouteTo, + ws.identifier as description, + ii.obj_id::varchar as tag, + wn.situation_geometry as geom, + CASE + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state, + CASE + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn.obj_id as obj_id +FROM qgep_od.infiltration_installation as ii +LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ii.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text +LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id +WHERE wn.obj_id IS NOT NULL +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) ; diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index 41b04bb2..56d367c3 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -81,27 +81,69 @@ SELECT END as hierarchy, wn_obj_id as obj_id FROM ( - SELECT ca.*, wn.situation_geometry as wn_geom, 'rw_current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic - FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = ca.fk_wastewater_networkelement_rw_current - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id - LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure - UNION ALL - SELECT ca.*, wn.situation_geometry as wn_geom, 'rw_planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic - FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = ca.fk_wastewater_networkelement_rw_planned - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id - LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure - UNION ALL - SELECT ca.*, wn.situation_geometry as wn_geom, 'ww_current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic - FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = ca.fk_wastewater_networkelement_ww_current - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id - LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure - UNION ALL - SELECT ca.*, wn.situation_geometry as wn_geom,'ww_planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic - FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = ca.fk_wastewater_networkelement_ww_planned - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id - LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure + SELECT ca_1.obj_id, + ddc.vsacode as direct_discharge_current, + ddp.vsacode as direct_discharge_planned, + ca_1.discharge_coefficient_rw_current, + ca_1.discharge_coefficient_rw_planned, + ca_1.discharge_coefficient_ww_current, + ca_1.discharge_coefficient_ww_planned, + dsc.vsacode as drainage_system_current, + dsp.vsacode as drainage_system_planned, + ca_1.identifier, + ic.vsacode as infiltration_current, + ip.vsacode as infiltration_planned, + ca_1.perimeter_geometry, + ca_1.population_density_current, + ca_1.population_density_planned, + ca_1.remark, + rc.vsacode as retention_current, + rp.vsacode as retention_planned, + ca_1.runoff_limit_current, + ca_1.runoff_limit_planned, + ca_1.seal_factor_rw_current, + ca_1.seal_factor_rw_planned, + ca_1.seal_factor_ww_current, + ca_1.seal_factor_ww_planned, + ca_1.sewer_infiltration_water_production_current, + ca_1.sewer_infiltration_water_production_planned, + ca_1.surface_area, + ca_1.waste_water_production_current, + ca_1.waste_water_production_planned, + ca_1.last_modification, + ca_1.fk_dataowner, + ca_1.fk_provider, + ca_1.fk_wastewater_networkelement_rw_current, + ca_1.fk_wastewater_networkelement_rw_planned, + ca_1.fk_wastewater_networkelement_ww_planned, + ca_1.fk_wastewater_networkelement_ww_current, + wn.situation_geometry AS wn_geom, + CASE WHEN ca_1.fk_wastewater_networkelement_rw_current =wn.obj_id + THEN 'rw_current'::text + WHEN ca_1.fk_wastewater_networkelement_ww_current =wn.obj_id + THEN 'ww_current'::text + WHEN ca_1.fk_wastewater_networkelement_rw_planned =wn.obj_id + THEN 'rw_planned'::text + WHEN ca_1.fk_wastewater_networkelement_ww_planned =wn.obj_id + THEN 'ww_planned'::text + ELSE 'ERROR' + END AS state, + wn.obj_id AS wn_obj_id, + fhy.vsacode as _function_hierarchic + FROM qgep_od.catchment_area ca_1 + JOIN qgep_od.wastewater_networkelement ne + ON ne.obj_id::text IN (ca_1.fk_wastewater_networkelement_rw_current::text, + ca_1.fk_wastewater_networkelement_ww_current::text, + ca_1.fk_wastewater_networkelement_rw_planned::text, + ca_1.fk_wastewater_networkelement_ww_planned::text) + LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id::text = ne.obj_id::text + LEFT JOIN qgep_vl.catchment_area_direct_discharge_current ddc ON ddc.code=ca_1.direct_discharge_current + LEFT JOIN qgep_vl.catchment_area_direct_discharge_planned ddp ON ddp.code=ca_1.direct_discharge_planned + LEFT JOIN qgep_vl.catchment_area_drainage_system_current dsc ON dsc.code=ca_1.drainage_system_current + LEFT JOIN qgep_vl.catchment_area_drainage_system_planned dsp ON dsp.code=ca_1.drainage_system_planned + LEFT JOIN qgep_vl.catchment_area_infiltration_current ic ON ic.code=ca_1.infiltration_current + LEFT JOIN qgep_vl.catchment_area_infiltration_planned ip ON ip.code=ca_1.infiltration_planned + LEFT JOIN qgep_vl.catchment_area_retention_current rc ON rc.code=ca_1.retention_current + LEFT JOIN qgep_vl.catchment_area_retention_planned rp ON rp.code=ca_1.retention_planned + LEFT JOIN qgep_vl.channel_function_hierarchic fhy ON fhy.code=wn._function_hierarchic ) as ca; diff --git a/swmm_views/10_vw_swmm_subareas.sql b/swmm_views/10_vw_swmm_subareas.sql index f7b0fbd6..c7b09376 100644 --- a/swmm_views/10_vw_swmm_subareas.sql +++ b/swmm_views/10_vw_swmm_subareas.sql @@ -25,35 +25,39 @@ SELECT wn_obj_id as obj_id FROM ( -SELECT ca.*, sr.surface_storage, 'rw_current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*, sr.surface_storage, 'rw_current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.surface_runoff_parameters sr ON ca.obj_id = sr.fk_catchment_area LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*, sr.surface_storage, 'ww_current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*, sr.surface_storage, 'ww_current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.surface_runoff_parameters sr ON ca.obj_id = sr.fk_catchment_area LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_ww_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_ww_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*, sr.surface_storage, 'rw_planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*, sr.surface_storage, 'rw_planned' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.surface_runoff_parameters sr ON ca.obj_id = sr.fk_catchment_area LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*, sr.surface_storage, 'ww_planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*, sr.surface_storage, 'ww_planned' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.surface_runoff_parameters sr ON ca.obj_id = sr.fk_catchment_area LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_ww_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; diff --git a/swmm_views/11_vw_swmm_dwf.sql b/swmm_views/11_vw_swmm_dwf.sql index ec55b874..bd093179 100644 --- a/swmm_views/11_vw_swmm_dwf.sql +++ b/swmm_views/11_vw_swmm_dwf.sql @@ -43,31 +43,35 @@ SELECT wn_obj_id as obj_id FROM ( -SELECT ca.*,'current' as state, 'rw_current' as type_ca, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'current' as state, 'rw_current' as type_ca, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'planned' as state, 'rw_planned' as type_ca, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'planned' as state, 'rw_planned' as type_ca, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'current' as state, 'ww_current' as type_ca, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'current' as state, 'ww_current' as type_ca, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_ww_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_ww_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'planned' as state, 'ww_planned' as type_ca, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'planned' as state, 'ww_planned' as type_ca, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_ww_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; diff --git a/swmm_views/12_vw_swmm_raingages.sql b/swmm_views/12_vw_swmm_raingages.sql index 80ae0133..8437a947 100644 --- a/swmm_views/12_vw_swmm_raingages.sql +++ b/swmm_views/12_vw_swmm_raingages.sql @@ -15,31 +15,35 @@ SELECT wn_obj_id as obj_id FROM ( -SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION -SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments UNION -SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_ww_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_ww_current IS NOT NULL -- to avoid unconnected catchments UNION -SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_ww_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; diff --git a/swmm_views/13_vw_swmm_infiltrations.sql b/swmm_views/13_vw_swmm_infiltrations.sql index fd319c85..cdd8f125 100644 --- a/swmm_views/13_vw_swmm_infiltrations.sql +++ b/swmm_views/13_vw_swmm_infiltrations.sql @@ -18,17 +18,19 @@ SELECT wn_obj_id as obj_id FROM ( -SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_current LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._function_hierarchic +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca LEFT JOIN qgep_od.wastewater_networkelement ne on ne.obj_id = fk_wastewater_networkelement_rw_planned LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = ne.obj_id LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; diff --git a/swmm_views/16_vw_swmm_pumps.sql b/swmm_views/16_vw_swmm_pumps.sql index b5472c3a..a055f9c2 100644 --- a/swmm_views/16_vw_swmm_pumps.sql +++ b/swmm_views/16_vw_swmm_pumps.sql @@ -20,26 +20,30 @@ SELECT CASE WHEN oc.obj_id IS NULL --'yes; THEN 'No curve will be created for this pump, it has no overflow_characteristic' - WHEN oc.overflow_characteristic_digital != 6223 --'yes; + WHEN vl_oc_dig.vsacode != 6223 --'yes; THEN 'No curve will be created for this pump, overflow_characteristic_digital not equal to yes' - WHEN oc.kind_overflow_characteristic != 6220 --'hq; + WHEN vl_oc_ki.vsacode != 6220 --'hq; THEN concat(pu.obj_id, 'No curve will be created for this pump, kind_overflow_characteristic is not equal to H/Q, Q/Q relations are not supported by SWMM') ELSE NULL END ) as description, pu.obj_id::varchar as tag, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.pump pu LEFT JOIN qgep_od.overflow of ON pu.obj_id = of.obj_id LEFT JOIN qgep_od.overflow_char oc ON of.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vl_oc_dig ON oc.overflow_characteristic_digital = vl_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vl_oc_ki ON oc.kind_overflow_characteristic = vl_oc_ki.code LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/18_vw_swmm_storages.sql b/swmm_views/18_vw_swmm_storages.sql index 5444f6a4..4094764a 100644 --- a/swmm_views/18_vw_swmm_storages.sql +++ b/swmm_views/18_vw_swmm_storages.sql @@ -27,16 +27,18 @@ SELECT CONCAT_WS(',','special_structure', ssf.value_en) as tag, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.special_structure ss LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ss.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id LEFT JOIN qgep_od.hydr_geometry hg on hg.obj_id = wn.fk_hydr_geometry @@ -46,7 +48,7 @@ LEFT JOIN ( ) as hr on hr.fk_hydr_geometry = hg.obj_id LEFT JOIN qgep_od.cover co on ws.fk_main_cover = co.obj_id LEFT JOIN qgep_vl.special_structure_function ssf on ss.function = ssf.code -WHERE ss.function IN ( -- must be the same list in vw_swmm_junctions +WHERE ssf.vsacode IN ( -- must be the same list in vw_swmm_junctions 6397, --"pit_without_drain" -- 245, --"drop_structure" 6398, --"hydrolizing_tank" @@ -78,7 +80,7 @@ WHERE ss.function IN ( -- must be the same list in vw_swmm_junctions -- 3008, --"unknown" -- 2745, --"vortex_manhole" ) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -106,16 +108,18 @@ SELECT CONCAT_WS(',','infiltration_installation', iik.value_en) as tag, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.infiltration_installation as ii LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ii.obj_id::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id LEFT JOIN qgep_od.hydr_geometry hg on hg.obj_id = wn.fk_hydr_geometry @@ -124,7 +128,7 @@ LEFT JOIN ( FROM qgep_od.hydr_geom_relation ) as hr on hr.fk_hydr_geometry = hg.obj_id LEFT JOIN qgep_vl.infiltration_installation_kind iik on ii.kind = iik.code -WHERE ii.kind IN ( +WHERE iik.vsacode IN ( --3282 --"with_soil_passage" --3285 --"without_soil_passage" --3279 --"surface_infiltration" @@ -137,7 +141,7 @@ WHERE ii.kind IN ( --278 --"adsorbing_well" --3283 --"infiltration_pipe_sections_gallery" ) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -163,7 +167,7 @@ SELECT 'Prank weir' as tag, wn.situation_geometry as geom, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE @@ -174,8 +178,12 @@ SELECT FROM qgep_od.prank_weir pw LEFT JOIN qgep_od.overflow of ON pw.obj_id = of.obj_id LEFT JOIN qgep_od.overflow_char oc ON of.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vl_oc_dig ON oc.overflow_characteristic_digital = vl_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vL_oc_ki ON oc.kind_overflow_characteristic = vL_oc_ki.code LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) -AND oc.overflow_characteristic_digital = 6223 --'yes; -AND oc.kind_overflow_characteristic = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND vl_oc_dig.vsacode = 6223 --'yes; +AND vL_oc_ki.vsacode = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) diff --git a/swmm_views/19_vw_swmm_outlets.sql b/swmm_views/19_vw_swmm_outlets.sql index 73f36951..2c507a1c 100644 --- a/swmm_views/19_vw_swmm_outlets.sql +++ b/swmm_views/19_vw_swmm_outlets.sql @@ -10,19 +10,23 @@ SELECT NULL as Qexpon, 'NO' as Gated, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.prank_weir pw LEFT JOIN qgep_od.overflow of ON pw.obj_id = of.obj_id LEFT JOIN qgep_od.overflow_char oc ON of.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vL_oc_dig ON oc.overflow_characteristic_digital = vL_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vl_oc_ki ON oc.kind_overflow_characteristic = vl_oc_ki.code LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) -AND oc.overflow_characteristic_digital = 6223 --'yes; -AND oc.kind_overflow_characteristic = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) \ No newline at end of file +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND vL_oc_dig.vsacode = 6223 --'yes; +AND vl_oc_ki.vsacode = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) diff --git a/swmm_views/21_vw_swmm_weirs.sql b/swmm_views/21_vw_swmm_weirs.sql index c9f41238..a994d478 100644 --- a/swmm_views/21_vw_swmm_weirs.sql +++ b/swmm_views/21_vw_swmm_weirs.sql @@ -16,11 +16,11 @@ SELECT NULL as RoadSurf, NULL as CoeffCurve, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id, @@ -28,11 +28,14 @@ SELECT FROM qgep_od.prank_weir pw LEFT JOIN qgep_od.overflow of ON pw.obj_id = of.obj_id LEFT JOIN qgep_od.overflow_char oc ON of.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vl_oc_dig ON oc.overflow_characteristic_digital = vl_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vl_oc_ki ON oc.kind_overflow_characteristic = vl_oc_ki.code LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node -LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) -AND (oc.overflow_characteristic_digital != 6223 OR oc.overflow_characteristic_digital IS NULL) --'yes; -OR (oc.kind_overflow_characteristic != 6220 OR oc.overflow_characteristic_digital IS NULL)-- h/q relations (Q/Q relations are not supported by SWMM) +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON wn._status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=wn._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND (vl_oc_dig.vsacode != 6223 OR vl_oc_dig.vsacode IS NULL) --'yes; +OR (vl_oc_ki.vsacode != 6220 OR vl_oc_ki.vsacode IS NULL)-- h/q relations (Q/Q relations are not supported by SWMM) UNION ALL @@ -52,11 +55,11 @@ SELECT NULL as RoadSurf, NULL as CoeffCurve, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id, @@ -64,6 +67,9 @@ SELECT FROM qgep_od.leapingweir lw LEFT JOIN qgep_od.overflow of ON lw.obj_id = of.obj_id LEFT JOIN qgep_od.overflow_char oc ON of.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vl_oc_dig ON oc.overflow_characteristic_digital = vl_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vl_oc_ki ON oc.kind_overflow_characteristic = vl_oc_ki.code LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node -LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON wn._status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=wn._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/22_vw_swmm_curves.sql b/swmm_views/22_vw_swmm_curves.sql index a192f5d5..ba13daea 100644 --- a/swmm_views/22_vw_swmm_curves.sql +++ b/swmm_views/22_vw_swmm_curves.sql @@ -14,23 +14,27 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_curves AS hq.altitude as XValue, hq.flow as YValue, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.hq_relation hq LEFT JOIN qgep_od.overflow_char oc ON hq.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vl_oc_dig ON oc.overflow_characteristic_digital = vl_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vl_oc_ki ON oc.kind_overflow_characteristic = vl_oc_ki.code LEFT JOIN qgep_od.overflow of ON of.fk_overflow_characteristic = oc.obj_id LEFT JOIN qgep_od.pump pu ON pu.obj_id = of.obj_id LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) -AND oc.overflow_characteristic_digital = 6223 --'yes; -AND oc.kind_overflow_characteristic = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND vl_oc_dig.vsacode = 6223 --'yes; +AND vl_oc_ki.vsacode = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) AND pu.obj_id IS NOT NULL ORDER BY pu.obj_id, hq.altitude) @@ -47,23 +51,27 @@ UNION ALL hq.altitude as XValue, hq.flow as YValue, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id FROM qgep_od.hq_relation hq LEFT JOIN qgep_od.overflow_char oc ON hq.fk_overflow_characteristic = oc.obj_id +LEFT JOIN qgep_vl.overflow_char_overflow_characteristic_digital vl_oc_dig ON oc.overflow_characteristic_digital = vl_oc_dig.code +LEFT JOIN qgep_vl.overflow_char_kind_overflow_characteristic vl_oc_ki ON oc.kind_overflow_characteristic = vl_oc_ki.code LEFT JOIN qgep_od.overflow of ON of.fk_overflow_characteristic = oc.obj_id LEFT JOIN qgep_od.prank_weir pw ON pw.obj_id = of.obj_id LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) -AND oc.overflow_characteristic_digital = 6223 --'yes; -AND oc.kind_overflow_characteristic = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND vl_oc_dig.vsacode = 6223 --'yes; +AND vl_oc_ki.vsacode = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) AND pw.obj_id IS NOT NULL ORDER BY pw.obj_id, hq.altitude) @@ -80,11 +88,11 @@ UNION ALL hr.water_depth as XValue, hr.water_surface as YValue, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id @@ -92,4 +100,6 @@ FROM qgep_od.hydr_geom_relation hr LEFT JOIN qgep_od.hydr_geometry hg on hg.obj_id = hr.fk_hydr_geometry LEFT JOIN qgep_od.wastewater_node wn on hg.obj_id = wn.fk_hydr_geometry LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -ORDER BY wn.obj_id, hr.water_depth) \ No newline at end of file +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +ORDER BY wn.obj_id, hr.water_depth) diff --git a/swmm_views/23_vw_swmm_xsections.sql b/swmm_views/23_vw_swmm_xsections.sql index 8ce815f9..a98d299e 100644 --- a/swmm_views/23_vw_swmm_xsections.sql +++ b/swmm_views/23_vw_swmm_xsections.sql @@ -6,12 +6,12 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_xsections AS SELECT DISTINCT re.obj_id as Link, CASE - WHEN pp.profile_type = 3350 THEN 'CIRCULAR' -- circle - WHEN pp.profile_type = 3353 THEN 'RECT_CLOSED' -- rectangular - WHEN pp.profile_type = 3351 THEN 'EGG' -- egg - WHEN pp.profile_type = 3355 THEN 'CUSTOM' -- special - WHEN pp.profile_type = 3352 THEN 'ARCH' -- mouth - WHEN pp.profile_type = 3354 THEN 'PARABOLIC' -- open + WHEN ppt.vsacode = 3350 THEN 'CIRCULAR' -- circle + WHEN ppt.vsacode = 3353 THEN 'RECT_CLOSED' -- rectangular + WHEN ppt.vsacode = 3351 THEN 'EGG' -- egg + WHEN ppt.vsacode = 3355 THEN 'CUSTOM' -- special + WHEN ppt.vsacode = 3352 THEN 'ARCH' -- mouth + WHEN ppt.vsacode = 3354 THEN 'PARABOLIC' -- open ELSE 'CIRCULAR' END as Shape, --Geom1 = height -> used for all the profile types @@ -22,7 +22,7 @@ SELECT DISTINCT END as Geom1, --Geom2 = width -> needed for profile rect_closed,arch and parabolic CASE - WHEN pp.profile_type IN (3352,3353,3354) THEN CASE + WHEN ppt.vsacode IN (3352,3353,3354) THEN CASE WHEN pp.height_width_ratio IS NOT NULL THEN CASE WHEN re.clear_height = 0 THEN 0.1/pp.height_width_ratio WHEN re.clear_height IS NULL THEN 0.1/pp.height_width_ratio @@ -39,20 +39,23 @@ SELECT DISTINCT 1 as Barrels, NULL as Culvert, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, re.obj_id as obj_id FROM qgep_od.reach re LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile +LEFT JOIN qgep_vl.pipe_profile_profile_type ppt on ppt.code =pp.profile_type LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ne.fk_wastewater_structure::text +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code LEFT JOIN qgep_od.channel ch ON ch.obj_id::text = ws.obj_id::text -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ch.function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -68,11 +71,11 @@ SELECT NULL as Barrels, NULL as Culvert, CASE - WHEN status IN (7959, 6529, 6526) THEN 'planned' + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, CASE - WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id @@ -81,8 +84,10 @@ LEFT JOIN qgep_od.overflow of ON pw.obj_id = of.obj_id LEFT JOIN qgep_od.overflow_char oc ON of.fk_overflow_characteristic = oc.obj_id LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = of.fk_wastewater_node LEFT JOIN qgep_od.wastewater_structure ws ON ws.fk_main_wastewater_node = wn.obj_id -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic +WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND oc.overflow_characteristic_digital != 6223 --'NO or unknown; OR oc.kind_overflow_characteristic != 6220 -- Q/Q relation or unknown -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/27_vw_swmm_results.sql b/swmm_views/27_vw_swmm_results.sql index 21e58e1b..09785dcd 100644 --- a/swmm_views/27_vw_swmm_results.sql +++ b/swmm_views/27_vw_swmm_results.sql @@ -1,6 +1,6 @@ CREATE OR REPLACE VIEW qgep_swmm.node_results AS -SELECT ws.obj_id AS ws_obj_id, ma.function AS ma_function, ss.function AS ss_function, +SELECT ws.obj_id AS ws_obj_id, mf.vsacode AS ma_function, ssf.vsacode AS ss_function, mp.obj_id AS mp_obj_id, mp.remark AS swmm_simulation_name, md.obj_id AS md_obj_id, ms.obj_id AS ms_obj_id, ms.dimension, ms.remark AS swmm_parameter, @@ -9,7 +9,9 @@ wn.situation_geometry AS geom FROM qgep_od.wastewater_structure ws JOIN qgep_od.wastewater_node wn ON wn.obj_id = ws.fk_main_wastewater_node LEFT JOIN qgep_od.manhole ma ON ma.obj_id = ws.obj_id +LEFT JOIN qgep_vl.manhole_function mf ON mf.code = ma.function LEFT JOIN qgep_od.special_structure ss ON ss.obj_id = ws.obj_id +LEFT JOIN qgep_vl.special_structure_function ssf ON ssf.code = ss.function LEFT JOIN qgep_od.measuring_point mp ON mp.fk_wastewater_structure = ws.obj_id LEFT JOIN qgep_od.measuring_device md ON md.fk_measuring_point = mp.obj_id LEFT JOIN qgep_od.measurement_series ms ON ms.fk_measuring_point = mp.obj_id @@ -32,4 +34,4 @@ LEFT JOIN qgep_od.measuring_device md ON md.fk_measuring_point = mp.obj_id LEFT JOIN qgep_od.measurement_series ms ON ms.fk_measuring_point = mp.obj_id LEFT JOIN qgep_od.measurement_result mr ON mr.fk_measurement_series = ms.obj_id WHERE md.remark = 'SWMM Simulation' -ORDER BY mp.obj_id, mr.time; \ No newline at end of file +ORDER BY mp.obj_id, mr.time;