From 1a8f44bd4d5be536f76e2bf1c87e15087004064f Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 11 Oct 2022 16:14:09 +0200 Subject: [PATCH 01/39] #730, #560 redirect correctly the catchments --- swmm_views/09_vw_swmm_subcatchments.sql | 67 +++++++++++++++++-------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index a6a5c4882..983499096 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -116,35 +116,58 @@ WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnecte -- Creates Dry Weather Flow related to the catchment area CREATE OR REPLACE VIEW qgep_swmm.vw_dwf AS SELECT - CASE - WHEN state = 'current' THEN fk_wastewater_networkelement_rw_current - WHEN state = 'planned' THEN fk_wastewater_networkelement_rw_planned - END as Node, -- id of the junction - 'FLOW'::varchar as Constituent, - CASE - WHEN surface_area IS NOT NULL - THEN - CASE - WHEN state = 'current' THEN population_density_current * surface_area * 160 / (24 * 60 * 60) - WHEN state = 'planned' THEN population_density_planned * surface_area * 160 / (24 * 60 * 60) - END - ELSE - CASE - WHEN state = 'current' THEN population_density_current * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) - WHEN state = 'planned' THEN population_density_planned * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) - END - END as Baseline, -- 160 Litre / inhabitant /day - 'dailyPatternDWF'::varchar as Patterns, - state as state + CASE + WHEN type_ca = 'rw_current' THEN fk_wastewater_networkelement_rw_current + WHEN type_ca = 'rw_planned' THEN fk_wastewater_networkelement_rw_planned + WHEN type_ca = 'ww_current' THEN fk_wastewater_networkelement_ww_current + WHEN type_ca = 'ww_planned' THEN fk_wastewater_networkelement_ww_planned + END as Node, -- id of the junction + 'FLOW'::varchar as Constituent, + CASE + WHEN fk_wastewater_networkelement_ww_current is not null + THEN + CASE + WHEN waste_water_production_current IS NOT NULL THEN waste_water_production_current + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + END + END + WHEN fk_wastewater_networkelement_ww_planned is not null + THEN + CASE + WHEN waste_water_production_planned IS NOT NULL THEN waste_water_production_planned + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + END + END + WHEN fk_wastewater_networkelement_rw_current is not null + THEN 0 + WHEN fk_wastewater_networkelement_rw_planned is not null + THEN 0 + END as Baseline, -- 160 Litre / inhabitant /day + 'dailyPatternDWF'::varchar as Patterns, + state as state FROM ( -SELECT ca.*,'current' as state +SELECT ca.*,'current' as state, 'rw_current' as type_ca FROM qgep_od.catchment_area as ca WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'planned' as state +SELECT ca.*,'planned' as state, 'rw_planned' as type_ca FROM qgep_od.catchment_area as ca 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 +FROM qgep_od.catchment_area as ca +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 +FROM qgep_od.catchment_area as ca +WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; -- Creates a default raingage for each subcatchment From b917353cfb65b88fa28996f9fd14791d416f205c Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 11 Oct 2022 16:28:23 +0200 Subject: [PATCH 02/39] #730, #560 add a column message to warn the user when default values are used --- swmm_views/09_vw_swmm_subcatchments.sql | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index 983499096..2110fa2e9 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -140,8 +140,8 @@ SELECT WHEN waste_water_production_planned IS NOT NULL THEN waste_water_production_planned ELSE CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) - ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_planned,0) * surface_area * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_planned,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) END END WHEN fk_wastewater_networkelement_rw_current is not null @@ -149,6 +149,32 @@ SELECT WHEN fk_wastewater_networkelement_rw_planned is not null THEN 0 END as Baseline, -- 160 Litre / inhabitant /day + CASE + WHEN fk_wastewater_networkelement_ww_current is not null + THEN + CASE + WHEN waste_water_production_current IS NOT NULL THEN 'DWF baseline is computed from waste_water_production_current' + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN 'DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day' + ELSE 'DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day' + END + END + WHEN fk_wastewater_networkelement_ww_planned is not null + THEN + CASE + WHEN waste_water_production_planned IS NOT NULL THEN 'DWF baseline is computed from waste_water_production_planned' + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN 'DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day' + ELSE 'DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day' + END + END + WHEN fk_wastewater_networkelement_rw_current is not null + THEN NULL + WHEN fk_wastewater_networkelement_rw_planned is not null + THEN NULL + END as message, -- 160 Litre / inhabitant /day 'dailyPatternDWF'::varchar as Patterns, state as state FROM From c4fb5ae67d8e9dc8b3495f92fd14a3ae3329cfb3 Mon Sep 17 00:00:00 2001 From: Produit Date: Wed, 12 Oct 2022 08:05:02 +0200 Subject: [PATCH 03/39] update DWF message --- swmm_views/09_vw_swmm_subcatchments.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index 2110fa2e9..1f50dfc0d 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -153,28 +153,28 @@ SELECT WHEN fk_wastewater_networkelement_ww_current is not null THEN CASE - WHEN waste_water_production_current IS NOT NULL THEN 'DWF baseline is computed from waste_water_production_current' + WHEN waste_water_production_current IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_current') ELSE CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN 'DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day' - ELSE 'DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day' + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day') + ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day') END END WHEN fk_wastewater_networkelement_ww_planned is not null THEN CASE - WHEN waste_water_production_planned IS NOT NULL THEN 'DWF baseline is computed from waste_water_production_planned' + WHEN waste_water_production_planned IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_planned') ELSE CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN 'DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day' - ELSE 'DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day' + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day') + ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day') END END WHEN fk_wastewater_networkelement_rw_current is not null - THEN NULL + THEN '' WHEN fk_wastewater_networkelement_rw_planned is not null - THEN NULL - END as message, -- 160 Litre / inhabitant /day + THEN '' + END as message, 'dailyPatternDWF'::varchar as Patterns, state as state FROM From 06f730d4fc46265c25690e9cb6e15c2decc6e36e Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 13 Oct 2022 08:59:05 +0200 Subject: [PATCH 04/39] typo in comment --- swmm_views/02_vw_swmm_junctions.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 9eacc38e0..a92e1196c 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -142,7 +142,7 @@ LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_struct LEFT JOIN qgep_od.reach_point rp_to ON rp_to.obj_id::text = re.fk_reach_point_from::text 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 --- Get wastewater structure linked to the from node +-- 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 -- select only the primary channels pwwf.* From 9654723e8545ff6be662f1fbba5b89c6fdd7ed9c Mon Sep 17 00:00:00 2001 From: RoMabillard Date: Thu, 13 Oct 2022 10:08:25 +0200 Subject: [PATCH 05/39] force 3D geom vw_conduites --- swmm_views/04_vw_swmm_conduits.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 6d1741637..f52699a5b 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -23,7 +23,7 @@ SELECT 0 as MaxFlow, ws.identifier::text as description, cfh.value_en as tag, - ST_SimplifyPreserveTopology(ST_CurveToLine(progression_geometry), 0.5)::geometry(LineStringZ, %(SRID)s) as geom, + ST_CurveToLine(st_force3d(progression_geometry))::geometry(LineStringZ, %(SRID)s) as geom, CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' From 31d1b3688de5c5b3ab180fb8fc27880199c06dff Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 13 Oct 2022 08:59:05 +0200 Subject: [PATCH 06/39] typo in comment --- swmm_views/02_vw_swmm_junctions.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 9eacc38e0..a92e1196c 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -142,7 +142,7 @@ LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_struct LEFT JOIN qgep_od.reach_point rp_to ON rp_to.obj_id::text = re.fk_reach_point_from::text 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 --- Get wastewater structure linked to the from node +-- 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 -- select only the primary channels pwwf.* From e1c56a89d5951a35e7fa79b20f5f9de7648a3773 Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 13 Oct 2022 10:20:52 +0200 Subject: [PATCH 07/39] add qgep_od.hydraulic_load attribute --- 03_qgep_db_dss.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index 29f1c2c06..a165a9f02 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -1914,6 +1914,9 @@ ALTER TABLE qgep_od.reach ADD COLUMN slope_building_plan smallint ; COMMENT ON COLUMN qgep_od.reach.slope_building_plan IS 'yyy_Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen. / Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen. / Pente indiquée sur d''anciens plans non contrôlée [%o]. Ne peut pas être reprise pour des calculs hydrauliques. Indication pour des canalisations de biens-fonds ou d''amélioration foncière. Représentation sur de plan: 3.5‰ p'; ALTER TABLE qgep_od.reach ADD COLUMN wall_roughness decimal(5,2) ; COMMENT ON COLUMN qgep_od.reach.wall_roughness IS 'yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb) / Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb) / Coefficient de rugosité d''après Prandtl Colebrook (ks ou kb)'; +ALTER TABLE qgep_od.reach ADD COLUMN hydraulic_load decimal(7,3) ; +COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS ''; + ------- CREATE TRIGGER update_last_modified_reach From bb063cb9ac0e0dec96ea3c3c27f8470aa49e0b24 Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 13 Oct 2022 13:49:11 +0200 Subject: [PATCH 08/39] remove useless comment --- 03_qgep_db_dss.sql | 2 +- swmm_views/04_vw_swmm_conduits.sql | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index a165a9f02..bffe1abdb 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -1915,7 +1915,7 @@ COMMENT ON COLUMN qgep_od.reach.slope_building_plan IS 'yyy_Auf dem alten Plan e ALTER TABLE qgep_od.reach ADD COLUMN wall_roughness decimal(5,2) ; COMMENT ON COLUMN qgep_od.reach.wall_roughness IS 'yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb) / Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb) / Coefficient de rugosité d''après Prandtl Colebrook (ks ou kb)'; ALTER TABLE qgep_od.reach ADD COLUMN hydraulic_load decimal(7,3) ; -COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS ''; +COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; ------- CREATE TRIGGER diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 6d1741637..681a51907 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -9,7 +9,6 @@ SELECT coalesce(from_wn.obj_id, 'default_qgep_node') as FromNode, coalesce(to_wn.obj_id, 'default_qgep_node') as ToNode, CASE - --WHEN re.length_effective <= 0.01 THEN st_length(progression_geometry) WHEN re.length_effective <= 0.01 AND st_length(progression_geometry) <= 0.01 THEN 0.01 WHEN re.length_effective <= 0.01 AND st_length(progression_geometry) >= 0.01 THEN st_length(progression_geometry) WHEN re.length_effective IS NULL AND st_length(progression_geometry) <= 0.01 THEN 0.01 From 24f8bfd9f3f39d47002bd7a9f8086d2dea2d82ca Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 18 Oct 2022 16:23:36 +0200 Subject: [PATCH 09/39] add hierarchy --- swmm_views/02_vw_swmm_junctions.sql | 34 +++++++++++++++++++---------- swmm_views/04_vw_swmm_conduits.sql | 10 +++++---- swmm_views/05_vw_swmm_dividers.sql | 14 ++++++++---- swmm_views/07_vw_swmm_losses.sql | 9 +++++--- swmm_views/08_vw_swmm_outfalls.sql | 7 ++++-- swmm_views/11_vw_swmm_pumps.sql | 9 +++++--- swmm_views/13_vw_swmm_storages.sql | 14 ++++++++---- swmm_views/14_vw_swmm_xsections.sql | 10 +++++---- 8 files changed, 71 insertions(+), 36 deletions(-) diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 9eacc38e0..153d50669 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -18,7 +18,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.manhole ma LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ma.obj_id::text LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -26,7 +30,6 @@ 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 WHERE wn.obj_id IS NOT NULL -AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959) UNION @@ -45,7 +48,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -53,7 +60,6 @@ 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 WHERE wn.obj_id IS NOT NULL -AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959) AND function NOT IN ( -- must be the same list in vw_swmm_storages 6397, --"pit_without_drain" @@ -104,7 +110,11 @@ SELECT CASE WHEN ws.status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.reach as re 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 @@ -114,10 +124,8 @@ 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 --- select only the primary channels pwwf.* -WHERE ch.function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -- select only operationals and "planned" -AND ws.status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE ws.status IN (6530, 6533, 8493, 6529, 6526, 7959) and ws_node is null UNION @@ -135,7 +143,11 @@ SELECT CASE WHEN ws.status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.reach as re 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 @@ -145,8 +157,6 @@ 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 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 --- select only the primary channels pwwf.* -WHERE ch.function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -- select only operationals and "planned" -AND ws.status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE ws.status 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 6d1741637..dc42788d5 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -27,7 +27,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.reach as re 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 @@ -37,10 +41,8 @@ LEFT JOIN qgep_od.wastewater_node from_wn on from_wn.obj_id = rp_from.fk_wastewa 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 --- select only the primary channels pwwf.* -WHERE ch.function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -- select only operationals and "planned" -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); +WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); -- 6526 "other.calculation_alternative" -- 6529 "other.project" -- 7959 "other.planned" diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index 95d381842..e0189d3bb 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -16,7 +16,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.manhole ma LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ma.obj_id::text LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -24,7 +28,6 @@ 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 WHERE function = 4798 -- separating_structure -AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -41,7 +44,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -49,5 +56,4 @@ 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 WHERE function = 4799 -- separating_structure -AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status 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 1b5e7c661..4748bc436 100644 --- a/swmm_views/07_vw_swmm_losses.sql +++ b/swmm_views/07_vw_swmm_losses.sql @@ -17,7 +17,11 @@ SELECT DISTINCT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.reach re LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile @@ -25,6 +29,5 @@ 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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE status 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 5f2d8c6f2..78eb36d75 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -17,12 +17,15 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy 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_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._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959) ; diff --git a/swmm_views/11_vw_swmm_pumps.sql b/swmm_views/11_vw_swmm_pumps.sql index 667d888fe..84e4e3522 100644 --- a/swmm_views/11_vw_swmm_pumps.sql +++ b/swmm_views/11_vw_swmm_pumps.sql @@ -21,9 +21,12 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.pump pu JOIN qgep_od.overflow overflow ON pu.obj_id::text = overflow.obj_id::text LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = pu.obj_id::text -WHERE ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); +WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/13_vw_swmm_storages.sql b/swmm_views/13_vw_swmm_storages.sql index 7dd720d88..7f1368802 100644 --- a/swmm_views/13_vw_swmm_storages.sql +++ b/swmm_views/13_vw_swmm_storages.sql @@ -24,7 +24,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -63,7 +67,6 @@ WHERE ss.function IN ( -- must be the same list in vw_swmm_junctions -- 3008, --"unknown" -- 2745, --"vortex_manhole" ) -AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL SELECT @@ -86,7 +89,11 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -105,5 +112,4 @@ WHERE ii.kind IN ( --278 --"adsorbing_well" --3283 --"infiltration_pipe_sections_gallery" ) -AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/14_vw_swmm_xsections.sql b/swmm_views/14_vw_swmm_xsections.sql index c89c425fb..6281aaf14 100644 --- a/swmm_views/14_vw_swmm_xsections.sql +++ b/swmm_views/14_vw_swmm_xsections.sql @@ -28,12 +28,14 @@ SELECT DISTINCT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy FROM qgep_od.reach re LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile 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_od.channel ch ON ch.obj_id::text = ws.obj_id::text -WHERE ch.function_hierarchic = ANY (ARRAY[5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074]) --- select only operationals and "planned" -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file +WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file From 1f1736d733f3aceac3eca880cf091b9278889eee Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 20 Oct 2022 17:19:05 +0200 Subject: [PATCH 10/39] add obj_id for selection --- swmm_views/02_vw_swmm_junctions.sql | 12 ++- swmm_views/04_vw_swmm_conduits.sql | 3 +- swmm_views/05_vw_swmm_dividers.sql | 14 +-- swmm_views/07_vw_swmm_losses.sql | 3 +- swmm_views/08_vw_swmm_outfalls.sql | 3 +- swmm_views/09_vw_swmm_subcatchments.sql | 123 ++++++++++++++++++------ swmm_views/10_vw_swmm_vertices.sql | 10 +- swmm_views/11_vw_swmm_pumps.sql | 5 +- swmm_views/12_vw_swmm_polygons.sql | 10 +- swmm_views/13_vw_swmm_storages.sql | 6 +- swmm_views/14_vw_swmm_xsections.sql | 3 +- swmm_views/15_vw_swmm_coordinates.sql | 20 +++- swmm_views/16_vw_swmm_tags.sql | 30 ++++-- 13 files changed, 182 insertions(+), 60 deletions(-) diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 153d50669..a77583780 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -22,7 +22,8 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + ws.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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -52,7 +53,8 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -114,7 +116,8 @@ SELECT CASE WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + from_wn.obj_id as obj_id FROM qgep_od.reach as re 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 @@ -147,7 +150,8 @@ SELECT CASE WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + to_wn.obj_id as obj_id FROM qgep_od.reach as re 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 diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index dc42788d5..3fab47ad7 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -31,7 +31,8 @@ SELECT CASE WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + re.obj_id as obj_id FROM qgep_od.reach as re 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 diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index e0189d3bb..922ad0a05 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -20,11 +20,12 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + 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_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.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 @@ -48,11 +49,12 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + 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_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.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 diff --git a/swmm_views/07_vw_swmm_losses.sql b/swmm_views/07_vw_swmm_losses.sql index 4748bc436..078269695 100644 --- a/swmm_views/07_vw_swmm_losses.sql +++ b/swmm_views/07_vw_swmm_losses.sql @@ -21,7 +21,8 @@ SELECT DISTINCT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + re.obj_id as obj_id FROM qgep_od.reach re LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile diff --git a/swmm_views/08_vw_swmm_outfalls.sql b/swmm_views/08_vw_swmm_outfalls.sql index 78eb36d75..cd1abb643 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -21,7 +21,8 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index a6a5c4882..8b781067f 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -50,23 +50,32 @@ SELECT WHEN state = 'rw_current' OR state = 'ww_current' THEN 'current' WHEN state = 'rw_planned' OR state = 'ww_planned' THEN 'planned' ELSE 'planned' - END as state + END as state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id FROM ( - SELECT ca.*, wn.situation_geometry as wn_geom, 'rw_current' as state FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement we on we.obj_id = ca.fk_wastewater_networkelement_rw_current - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id + 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 FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement we on we.obj_id = ca.fk_wastewater_networkelement_rw_planned - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id + 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 FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement we on we.obj_id = ca.fk_wastewater_networkelement_ww_current - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id + 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 FROM qgep_od.catchment_area as ca - INNER JOIN qgep_od.wastewater_networkelement we on we.obj_id = ca.fk_wastewater_networkelement_ww_planned - LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id + 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 ) as ca; @@ -89,27 +98,44 @@ SELECT NULL::float as PctRouted, ca.identifier || ', ' || ca.remark as description, ca.obj_id::varchar as tag, - state as state + state as state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id FROM ( -SELECT ca.*, sr.surface_storage, 'rw_current' as state +SELECT ca.*, sr.surface_storage, 'rw_current' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*, sr.surface_storage, 'ww_current' as state +SELECT ca.*, sr.surface_storage, 'ww_current' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_ww_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*, sr.surface_storage, 'rw_planned' as state +SELECT ca.*, sr.surface_storage, 'rw_planned' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*, sr.surface_storage, 'ww_planned' as state +SELECT ca.*, sr.surface_storage, 'ww_planned' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; @@ -135,15 +161,26 @@ SELECT END END as Baseline, -- 160 Litre / inhabitant /day 'dailyPatternDWF'::varchar as Patterns, - state as state + state as state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id FROM ( -SELECT ca.*,'current' as state +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'planned' as state +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; @@ -156,23 +193,40 @@ SELECT '1.0'::varchar as SCF, 'TIMESERIES default_qgep_raingage_timeserie'::varchar as Source, st_centroid(perimeter_geometry)::geometry(Point, %(SRID)s) as geom, - state + state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id FROM ( -SELECT ca.*,'current' as state +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION -SELECT ca.*,'planned' as state +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments UNION -SELECT ca.*,'current' as state +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_ww_current IS NOT NULL -- to avoid unconnected catchments UNION -SELECT ca.*,'planned' as state +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; @@ -188,15 +242,26 @@ SELECT 4 as Decay, 7 as DryTime, 0 as MaxInfil, - state + state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id FROM ( -SELECT ca.*,'current' as state +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_current IS NOT NULL -- to avoid unconnected catchments UNION ALL -SELECT ca.*,'planned' as state +SELECT ca.*,'planned' as state, wn.obj_id as wn_obj_id, ws._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 WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments ) as ca; diff --git a/swmm_views/10_vw_swmm_vertices.sql b/swmm_views/10_vw_swmm_vertices.sql index d317919ee..390592fbb 100644 --- a/swmm_views/10_vw_swmm_vertices.sql +++ b/swmm_views/10_vw_swmm_vertices.sql @@ -7,12 +7,18 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_vertices AS SELECT link, ROUND(ST_X((dp).geom)::numeric,2) as X_Coord, - ROUND(ST_Y((dp).geom)::numeric,2) as Y_Coord + ROUND(ST_Y((dp).geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id FROM ( SELECT Name As Link, ST_DumpPoints(geom) AS dp, - ST_NPoints(geom) as nvert + ST_NPoints(geom) as nvert, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_conduits ) as foo WHERE (dp).path[1] != 1 -- dont select first vertice diff --git a/swmm_views/11_vw_swmm_pumps.sql b/swmm_views/11_vw_swmm_pumps.sql index 84e4e3522..bf56d0c86 100644 --- a/swmm_views/11_vw_swmm_pumps.sql +++ b/swmm_views/11_vw_swmm_pumps.sql @@ -25,8 +25,11 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + wn.obj_id as obj_id FROM qgep_od.pump pu JOIN qgep_od.overflow overflow ON pu.obj_id::text = overflow.obj_id::text LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = pu.obj_id::text +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 WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/12_vw_swmm_polygons.sql b/swmm_views/12_vw_swmm_polygons.sql index 506adcf23..9a0d0a160 100644 --- a/swmm_views/12_vw_swmm_polygons.sql +++ b/swmm_views/12_vw_swmm_polygons.sql @@ -7,12 +7,18 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_polygons AS SELECT Subcatchment, round(ST_X((dp).geom)::numeric,2) as X_Coord, - round(ST_Y((dp).geom)::numeric,2) as Y_Coord + round(ST_Y((dp).geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id FROM ( SELECT Name As Subcatchment, ST_DumpPoints(geom) AS dp, - ST_NPoints(geom) as nvert + ST_NPoints(geom) as nvert, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_subcatchments ) as foo WHERE (dp).path[2] != nvert; -- dont select last vertex diff --git a/swmm_views/13_vw_swmm_storages.sql b/swmm_views/13_vw_swmm_storages.sql index 7f1368802..6441a5ab8 100644 --- a/swmm_views/13_vw_swmm_storages.sql +++ b/swmm_views/13_vw_swmm_storages.sql @@ -28,7 +28,8 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -93,7 +94,8 @@ SELECT CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + END as hierarchy, + ws.obj_id as ws_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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text diff --git a/swmm_views/14_vw_swmm_xsections.sql b/swmm_views/14_vw_swmm_xsections.sql index 6281aaf14..1798a64b2 100644 --- a/swmm_views/14_vw_swmm_xsections.sql +++ b/swmm_views/14_vw_swmm_xsections.sql @@ -32,7 +32,8 @@ SELECT DISTINCT CASE WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' - END as hierarchy + 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_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text diff --git a/swmm_views/15_vw_swmm_coordinates.sql b/swmm_views/15_vw_swmm_coordinates.sql index 0c7895865..372ea1ce7 100644 --- a/swmm_views/15_vw_swmm_coordinates.sql +++ b/swmm_views/15_vw_swmm_coordinates.sql @@ -7,7 +7,10 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_coordinates AS SELECT Name as Node, ROUND(ST_X(geom)::numeric,2) as X_Coord, - ROUND(ST_Y(geom)::numeric,2) as Y_Coord + ROUND(ST_Y(geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_junctions WHERE geom IS NOT NULL @@ -16,7 +19,10 @@ UNION SELECT Name as Node, ROUND(ST_X(geom)::numeric,2) as X_Coord, - ROUND(ST_Y(geom)::numeric,2) as Y_Coord + ROUND(ST_Y(geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_outfalls WHERE geom IS NOT NULL @@ -34,7 +40,10 @@ UNION SELECT Name as Node, ROUND(ST_X(geom)::numeric,2) as X_Coord, - ROUND(ST_Y(geom)::numeric,2) as Y_Coord + ROUND(ST_Y(geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_storages WHERE geom IS NOT NULL @@ -43,6 +52,9 @@ UNION SELECT Name as Node, ROUND(ST_X(geom)::numeric,2) as X_Coord, - ROUND(ST_Y(geom)::numeric,2) as Y_Coord + ROUND(ST_Y(geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_raingages WHERE geom IS NOT NULL; diff --git a/swmm_views/16_vw_swmm_tags.sql b/swmm_views/16_vw_swmm_tags.sql index e95cc2b89..4c0fdca19 100644 --- a/swmm_views/16_vw_swmm_tags.sql +++ b/swmm_views/16_vw_swmm_tags.sql @@ -7,7 +7,10 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_tags AS SELECT 'Node' as type, name as name, - tag as value + tag as value, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_junctions WHERE tag IS NOT NULL @@ -16,7 +19,10 @@ UNION SELECT 'Node' as type, name as name, - tag as value + tag as value, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_outfalls WHERE tag IS NOT NULL @@ -25,7 +31,10 @@ UNION SELECT 'Node' as type, name as name, - tag as value + tag as value, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_storages WHERE tag IS NOT NULL @@ -34,7 +43,10 @@ UNION SELECT 'Link' as type, name as name, - tag as value + tag as value, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_conduits WHERE tag IS NOT NULL @@ -43,7 +55,10 @@ UNION SELECT 'Link' as type, name as name, - tag as value + tag as value, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_pumps WHERE tag IS NOT NULL @@ -52,6 +67,9 @@ UNION SELECT 'Subcatch' as type, name as name, - tag as value + tag as value, + state, + hierarchy, + obj_id FROM qgep_swmm.vw_subcatchments WHERE tag IS NOT NULL; From b8dc9e5e4aee4b6e0fe79bcddc60c82a6ce90aca Mon Sep 17 00:00:00 2001 From: RoMabillard Date: Thu, 27 Oct 2022 14:13:53 +0200 Subject: [PATCH 11/39] compute roughness using Strickler or Colebrook vw_conduites --- swmm_views/04_vw_swmm_conduits.sql | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 6d1741637..15a9c0087 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -16,7 +16,16 @@ SELECT WHEN re.length_effective IS NULL AND st_length(progression_geometry) >= 0.01 THEN st_length(progression_geometry) ELSE re.length_effective END as Length, - coalesce(re.wall_roughness,0.01) as Roughness, + CASE + WHEN re.coefficient_of_friction IS NOT NULL THEN (1 / re.coefficient_of_friction::double precision) + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN + CASE + WHEN re.clear_height IS NOT NULL THEN (1 / (4 * SQRT(9.81) * POWER((32 / re.clear_height::double precision / 1000),(1 / 6::double precision))*LOG(((3.71 * re.clear_height::double precision / 1000) / (re.wall_roughness / 1000)))))::numeric(7,4) + ELSE 0.01 + END + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN 0.01 + ELSE 0.01 + END AS roughness, coalesce((rp_from.level-from_wn.bottom_level),0) as InletOffset, coalesce((rp_to.level-to_wn.bottom_level),0) as OutletOffset, 0 as InitFlow, @@ -27,7 +36,17 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN re.coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': 1 / K_Strickler is used as roughness') + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN + CASE + WHEN re.clear_height IS NOT NULL THEN concat('Reach ', re.obj_id,': The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness') + ELSE concat('Reach ', re.obj_id,': Default value is used as roughness since no approximation of 1 / K_Strickler can be computed due to missing information about the channel diameter') + END + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN concat('Reach ', re.obj_id,': Default value is used as roughness') + ELSE concat('Reach ', re.obj_id,': Default value is used as roughness') + END AS message FROM qgep_od.reach as re 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 From 04f3344c9937ae4608e3f325607c325c3d824008 Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 28 Oct 2022 13:55:06 +0200 Subject: [PATCH 12/39] hierarchy and obj_id in vertices --- swmm_views/03_vw_swmm_aquifers.sql | 4 +++- swmm_views/10_vw_swmm_vertices.sql | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/swmm_views/03_vw_swmm_aquifers.sql b/swmm_views/03_vw_swmm_aquifers.sql index 7b8cafa86..28527b908 100644 --- a/swmm_views/03_vw_swmm_aquifers.sql +++ b/swmm_views/03_vw_swmm_aquifers.sql @@ -18,5 +18,7 @@ SELECT minimal_groundwater_level as BottomElevation, average_groundwater_level as WaterTableElevation, 0.3 as UnsatZoneMoisture, - null as UpperEvapPattern + null as UpperEvapPattern, + null as state, + null as hierarchy FROM qgep_od.aquifier as aq; diff --git a/swmm_views/10_vw_swmm_vertices.sql b/swmm_views/10_vw_swmm_vertices.sql index 390592fbb..b6e9eaed7 100644 --- a/swmm_views/10_vw_swmm_vertices.sql +++ b/swmm_views/10_vw_swmm_vertices.sql @@ -10,7 +10,7 @@ SELECT ROUND(ST_Y((dp).geom)::numeric,2) as Y_Coord, state, hierarchy, - obj_id + ws_obj_id FROM ( SELECT Name As Link, @@ -18,7 +18,7 @@ FROM ( ST_NPoints(geom) as nvert, state, hierarchy, - obj_id + ws_obj_id FROM qgep_swmm.vw_conduits ) as foo WHERE (dp).path[1] != 1 -- dont select first vertice From 58982d9d2399971e2a3a3b259c3a362df31157d1 Mon Sep 17 00:00:00 2001 From: RoMabillard Date: Thu, 3 Nov 2022 09:56:09 +0100 Subject: [PATCH 13/39] Populate qgep_swmm.vw_conduits with default friction from qgep_swmm.reach_coefficient_of_friction --- 03_qgep_db_dss.sql | 2 ++ ...ta_1.X.X_tbl_swmm_coefficient_friction.sql | 10 ++++++++++ swmm_views/04_vw_swmm_conduits.sql | 20 ++++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 delta/delta_1.X.X_tbl_swmm_coefficient_friction.sql diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index 29f1c2c06..378c0f531 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -1887,6 +1887,8 @@ ALTER TABLE qgep_od.reach ADD COLUMN clear_height integer ; COMMENT ON COLUMN qgep_od.reach.clear_height IS 'Maximal height (inside) of profile / Maximale Innenhöhe des Kanalprofiles / Hauteur intérieure maximale du profil'; ALTER TABLE qgep_od.reach ADD COLUMN coefficient_of_friction smallint ; COMMENT ON COLUMN qgep_od.reach.coefficient_of_friction IS 'yyy http://www.linguee.com/english-german/search?source=auto&query=reibungsbeiwert / Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Manning-Strickler (K oder kstr) / Constante de rugosité selon Manning-Strickler (K ou kstr)'; +ALTER TABLE qgep_od.reach ADD COLUMN default_coefficient_of_friction smallint ; +COMMENT ON COLUMN qgep_od.reach.default_coefficient_of_friction IS 'yyy http://www.fsl.orst.edu/geowater/FX3/help/8_Hydraulic_Reference/Mannings_n_Tables.htm / (1 / N_Manning) value between 0 and 999'; ALTER TABLE qgep_od.reach ADD COLUMN elevation_determination integer ; COMMENT ON COLUMN qgep_od.reach.elevation_determination IS 'yyy_Definiert die Hoehenbestimmung einer Haltung. / Definiert die Hoehenbestimmung einer Haltung. / Définition de la détermination altimétrique d''un tronçon.'; ALTER TABLE qgep_od.reach ADD COLUMN horizontal_positioning integer ; diff --git a/delta/delta_1.X.X_tbl_swmm_coefficient_friction.sql b/delta/delta_1.X.X_tbl_swmm_coefficient_friction.sql new file mode 100644 index 000000000..252769518 --- /dev/null +++ b/delta/delta_1.X.X_tbl_swmm_coefficient_friction.sql @@ -0,0 +1,10 @@ +CREATE TABLE qgep_swmm.reach_coefficient_of_friction (fk_material integer, coefficient_of_friction smallint); +ALTER TABLE qgep_swmm.reach_coefficient_of_friction ADD CONSTRAINT pkey_qgep_vl_reach_coefficient_of_friction_id PRIMARY KEY (fk_material); +INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) SELECT vsacode FROM qgep_vl.reach_material; +UPDATE qgep_swmm.reach_coefficient_of_friction SET coefficient_of_friction = (CASE WHEN fk_material IN (5381,5081,3016) THEN 100 + WHEN fk_material IN (2754,3638,3639,3640,3641,3256,147,148,3648,5079,5080,153,2762) THEN 83 + WHEN fk_material IN (2755) THEN 67 + WHEN fk_material IN (5076,5077,5078,5382) THEN 111 + WHEN fk_material IN (3654) THEN 91 + WHEN fk_material IN (154,2761) THEN 71 + ELSE 100 END); \ No newline at end of file diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 15a9c0087..2247fb3f6 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -21,9 +21,14 @@ SELECT WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN CASE WHEN re.clear_height IS NOT NULL THEN (1 / (4 * SQRT(9.81) * POWER((32 / re.clear_height::double precision / 1000),(1 / 6::double precision))*LOG(((3.71 * re.clear_height::double precision / 1000) / (re.wall_roughness / 1000)))))::numeric(7,4) + WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN (1 / re.default_coefficient_of_friction::double precision) + ELSE 0.01 + END + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN + CASE + WHEN re.default_coefficient_of_friction IS NOT NULL THEN (1 / re.default_coefficient_of_friction::double precision) ELSE 0.01 END - WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN 0.01 ELSE 0.01 END AS roughness, coalesce((rp_from.level-from_wn.bottom_level),0) as InletOffset, @@ -41,11 +46,16 @@ SELECT WHEN re.coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': 1 / K_Strickler is used as roughness') WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN CASE - WHEN re.clear_height IS NOT NULL THEN concat('Reach ', re.obj_id,': The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness') - ELSE concat('Reach ', re.obj_id,': Default value is used as roughness since no approximation of 1 / K_Strickler can be computed due to missing information about the channel diameter') + WHEN re.clear_height IS NOT NULL THEN concat('Reach ', re.obj_id,': The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness as roughness') + WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': The default value stored in qgep_swmm.reach_coefficient_of_friction is used') + ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') + END + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN + CASE + WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': The default value stored in qgep_swmm.reach_coefficient_of_friction is used') + ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') END - WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN concat('Reach ', re.obj_id,': Default value is used as roughness') - ELSE concat('Reach ', re.obj_id,': Default value is used as roughness') + ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') END AS message FROM qgep_od.reach as re LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text From f7c15304d7fceb07e40582f9c0b00423df4668cd Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 8 Nov 2022 15:42:29 +0100 Subject: [PATCH 14/39] test export --- swmm_views/02_vw_swmm_junctions.sql | 2 +- swmm_views/03_vw_swmm_aquifers.sql | 4 +--- swmm_views/10_vw_swmm_vertices.sql | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index a77583780..5ce9937fb 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -23,7 +23,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - ws.obj_id as obj_id + 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text diff --git a/swmm_views/03_vw_swmm_aquifers.sql b/swmm_views/03_vw_swmm_aquifers.sql index 28527b908..7b8cafa86 100644 --- a/swmm_views/03_vw_swmm_aquifers.sql +++ b/swmm_views/03_vw_swmm_aquifers.sql @@ -18,7 +18,5 @@ SELECT minimal_groundwater_level as BottomElevation, average_groundwater_level as WaterTableElevation, 0.3 as UnsatZoneMoisture, - null as UpperEvapPattern, - null as state, - null as hierarchy + null as UpperEvapPattern FROM qgep_od.aquifier as aq; diff --git a/swmm_views/10_vw_swmm_vertices.sql b/swmm_views/10_vw_swmm_vertices.sql index b6e9eaed7..390592fbb 100644 --- a/swmm_views/10_vw_swmm_vertices.sql +++ b/swmm_views/10_vw_swmm_vertices.sql @@ -10,7 +10,7 @@ SELECT ROUND(ST_Y((dp).geom)::numeric,2) as Y_Coord, state, hierarchy, - ws_obj_id + obj_id FROM ( SELECT Name As Link, @@ -18,7 +18,7 @@ FROM ( ST_NPoints(geom) as nvert, state, hierarchy, - ws_obj_id + obj_id FROM qgep_swmm.vw_conduits ) as foo WHERE (dp).path[1] != 1 -- dont select first vertice From 850e7b391926039594afe65e7b11d057c66713aa Mon Sep 17 00:00:00 2001 From: RoMabillard Date: Tue, 8 Nov 2022 20:34:24 +0100 Subject: [PATCH 15/39] Set the profile parameters Geom1, Geom2, Geom3 correctly --- swmm_views/14_vw_swmm_xsections.sql | 72 +++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/swmm_views/14_vw_swmm_xsections.sql b/swmm_views/14_vw_swmm_xsections.sql index c89c425fb..b7a8f8e2b 100644 --- a/swmm_views/14_vw_swmm_xsections.sql +++ b/swmm_views/14_vw_swmm_xsections.sql @@ -7,20 +7,34 @@ 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 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 ELSE 'CIRCULAR' END as Shape, + --ROMA: Geom1 = height -> used for all the profile types CASE WHEN re.clear_height = 0 THEN 0.1 WHEN re.clear_height IS NULL THEN 0.1 ELSE re.clear_height/1000::float -- [mm] to [m] END as Geom1, - 0 as Geom2, + --ROMA: Geom2 = width -> needed for profile rect_closed,arch and parabolic + CASE + WHEN pp.profile_type 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 + ELSE re.clear_height/1000::float/pp.height_width_ratio + END + WHEN pp.height_width_ratio IS NULL THEN 0.002 --ROMA: TODO default value for width to be set + ELSE 0.002 --ROMA: TODO default value for width to be set + END + ELSE NULL + END as Geom2, + --ROMA: Geom3 = code -> used only for arch profile, but this code value is nowhere to be set in the QGEP model 0 as Geom3, 0 as Geom4, 1 as Barrels, @@ -28,7 +42,49 @@ SELECT DISTINCT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + --ROMA: message give details about the profile type, height availability, width availability if needed and code availablitity if needed. To much details? + CASE + WHEN pp.profile_type = 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 concat('Reach', re.obj_id,': circular profile with known clear_height value') + END + WHEN pp.profile_type = 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 concat('Reach', re.obj_id,': egg profile with known clear_height value') + END + WHEN pp.profile_type = 3352 THEN CASE + WHEN pp.height_width_ratio IS NOT NULL THEN CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with known height_width_ratio value and with default value of 0.1m as clear_height') + ELSE concat('Reach', re.obj_id,': arch profile with known height_width_ratio value and with known clear_height value') + END + WHEN pp.height_width_ratio IS NULL THEN CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') + 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 CASE + WHEN pp.height_width_ratio IS NOT NULL THEN CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with known height_width_ratio value and with default value of 0.1m as clear_height') + ELSE concat('Reach', re.obj_id,': rectangular profile with known height_width_ratio value and with known clear_height value') + END + WHEN pp.height_width_ratio IS NULL THEN CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') + 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 CASE + WHEN pp.height_width_ratio IS NOT NULL THEN CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with known height_width_ratio value, default value of 0.1m as clear_height and no code value') + ELSE concat('Reach', re.obj_id,': parabolic profile with known height_width_ratio value, with known clear_height value and no code value') + END + WHEN pp.height_width_ratio IS NULL THEN CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with default value of 1 as height_width_ratio, with default value of 0.1m as clear_height and no code value') + 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') + END as message FROM qgep_od.reach re LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text From 397914b086650b33a7ce6675c589b5a44748edd0 Mon Sep 17 00:00:00 2001 From: Produit Date: Wed, 9 Nov 2022 14:58:42 +0100 Subject: [PATCH 16/39] no from node and / or no to node --- swmm_views/02_vw_swmm_junctions.sql | 22 +++++++++++----------- swmm_views/04_vw_swmm_conduits.sql | 10 +++++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 5ce9937fb..2291175b4 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -100,15 +100,15 @@ UNION -- wastewater_node not linked to wastewater structures SELECT - from_wn.obj_id as Name, - coalesce(from_wn.bottom_level,0) as InvertElev, + coalesce(from_wn.obj_id, concat('from_node@',re.obj_id)) as Name, + coalesce(from_wn.bottom_level, 0) as InvertElev, 0 as MaxDepth, NULL::float as InitDepth, NULL::float as SurchargeDepth, NULL::float as PondedArea, - from_wn.obj_id as description, + coalesce(from_wn.obj_id, concat('from_node@',re.obj_id)) as description, 'junction without structure' as tag, - from_wn.situation_geometry as geom, + coalesce(from_wn.situation_geometry, ST_StartPoint(re.progression_geometry)) as geom, CASE WHEN ws.status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' @@ -117,7 +117,7 @@ SELECT WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - from_wn.obj_id as obj_id + coalesce(from_wn.obj_id, re.obj_id) as obj_id FROM qgep_od.reach as re 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 @@ -134,15 +134,15 @@ and ws_node is null UNION SELECT - to_wn.obj_id as Name, - coalesce(to_wn.bottom_level,0) as InvertElev, + coalesce(to_wn.obj_id, concat('to_node@',re.obj_id)) as Name, + coalesce(to_wn.bottom_level, 0) as InvertElev, 0 as MaxDepth, NULL::float as InitDepth, NULL::float as SurchargeDepth, NULL::float as PondedArea, - to_wn.obj_id as description, + coalesce(to_wn.obj_id, concat('to_node@',re.obj_id)) as description, 'junction without structure' as tag, - to_wn.situation_geometry as geom, + coalesce(to_wn.situation_geometry, ST_EndPoint(re.progression_geometry)) as geom, CASE WHEN ws.status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' @@ -151,11 +151,11 @@ SELECT WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - to_wn.obj_id as obj_id + coalesce(to_wn.obj_id, re.obj_id) as obj_id FROM qgep_od.reach as re 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_to ON rp_to.obj_id::text = re.fk_reach_point_from::text +LEFT JOIN qgep_od.reach_point rp_to ON rp_to.obj_id::text = re.fk_reach_point_to::text 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 -- Get wastewater structure linked to the from node diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 3fab47ad7..419cc74e1 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -6,8 +6,8 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_conduits AS SELECT re.obj_id as Name, - coalesce(from_wn.obj_id, 'default_qgep_node') as FromNode, - coalesce(to_wn.obj_id, 'default_qgep_node') as ToNode, + coalesce(from_wn.obj_id, concat('from_node@',re.obj_id)) as FromNode, + coalesce(to_wn.obj_id, concat('to_node@',re.obj_id)) as ToNode, CASE --WHEN re.length_effective <= 0.01 THEN st_length(progression_geometry) WHEN re.length_effective <= 0.01 AND st_length(progression_geometry) <= 0.01 THEN 0.01 @@ -32,7 +32,11 @@ SELECT WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - re.obj_id as obj_id + re.obj_id as obj_id, + CASE + WHEN to_wn.obj_id IS NULL THEN concat(re.obj_id, ' is a blind connection, the destionation node must be edited in SWMM.') + WHEN from_wn.obj_id IS NULL AND to_wn.obj_id IS NOT NULL THEN concat(re.obj_id, ' has no from node, a junction is automatically created for the export.') + END AS message FROM qgep_od.reach as re 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 From 2ba7c48b22891c21854e3866fa95557ac5480b6a Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 10 Nov 2022 15:58:03 +0100 Subject: [PATCH 17/39] change to export special structures --- swmm_views/11_vw_swmm_pumps.sql | 26 ++++++--- swmm_views/13_vw_swmm_storages.sql | 74 +++++++++++++++++++++++--- swmm_views/14_vw_swmm_outlets.sql | 24 +++++++++ swmm_views/14_vw_swmm_xsections.sql | 28 +++++++++- swmm_views/15_vw_swmm_orifices.sql | 12 +++++ swmm_views/15_vw_swmm_weirs.sql | 61 +++++++++++++++++++++ swmm_views/16_vw_swmm_tags.sql | 1 - swmm_views/17_vw_swmm_curves.sql | 82 +++++++++++++++++++++++++++++ 8 files changed, 290 insertions(+), 18 deletions(-) create mode 100644 swmm_views/14_vw_swmm_outlets.sql create mode 100644 swmm_views/15_vw_swmm_orifices.sql create mode 100644 swmm_views/15_vw_swmm_weirs.sql create mode 100644 swmm_views/17_vw_swmm_curves.sql diff --git a/swmm_views/11_vw_swmm_pumps.sql b/swmm_views/11_vw_swmm_pumps.sql index 667d888fe..5e19e97db 100644 --- a/swmm_views/11_vw_swmm_pumps.sql +++ b/swmm_views/11_vw_swmm_pumps.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class pumps --- 20190329 qgep code sprint SB, TP -- A pump in qgep is a node but a link in SWMM -- -> The pump is attached to the reach which goes out from the pump -- -> inlet node is the water node where the QGEP pump is located @@ -10,20 +9,31 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_pumps AS SELECT pu.obj_id as Name, - overflow.fk_wastewater_node as FromNode, -- inlet is the waternode entering the pump - overflow.fk_overflow_to as ToNode, -- outlet is the waternode at the top of next reach - 'default_qgep_pump_curve'::varchar as PumpCurve, + of.fk_wastewater_node as FromNode, -- inlet is the waternode entering the pump + of.fk_overflow_to as ToNode, -- outlet is the waternode at the top of next reach + concat('pump_curve@',pu.obj_id)::varchar as PumpCurve, 'ON'::varchar as Status, pu.start_level as StartupDepth, pu.stop_level as ShutoffDepth, - overflow.identifier as description, + of.identifier as description, pu.obj_id::varchar as tag, CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN oc.obj_id IS NULL --'yes; + THEN concat(pu.obj_id, ' No curve will be created for this pump, it has no overflow_characteristic') + WHEN oc.overflow_characteristic_digital != 6223 --'yes; + THEN concat(pu.obj_id, ' No curve will be created for this pump, overflow_characteristic_digital not equal to yes') + WHEN oc.kind_overflow_characteristic != 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 message FROM qgep_od.pump pu -JOIN qgep_od.overflow overflow ON pu.obj_id::text = overflow.obj_id::text -LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = pu.obj_id::text +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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) AND status IN (6530, 6533, 8493, 6529, 6526, 7959); diff --git a/swmm_views/13_vw_swmm_storages.sql b/swmm_views/13_vw_swmm_storages.sql index 7dd720d88..c473da791 100644 --- a/swmm_views/13_vw_swmm_storages.sql +++ b/swmm_views/13_vw_swmm_storages.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class storages --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_storages AS @@ -9,8 +8,14 @@ SELECT coalesce(wn.bottom_level,0) as InvertElev, coalesce((co.level-wn.bottom_level),0) as MaxDepth, 0 as InitDepth, - 'FUNCTIONAL' as Shape, - 1000 as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR + CASE + WHEN hr.fk_hydr_geometry IS NOT NULL THEN 'TABULAR' + ELSE 'FUNCTIONAL' + END as Shape, + CASE + WHEN hr.fk_hydr_geometry IS NOT NULL THEN concat('storageCurve@', wn.obj_id) + ELSE '0' + END as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR 0 as CurveExponent, -- if FONCTIONAL 0 as CurveConstant, -- if FONCTIONAL 0 as SurchargeDepth, @@ -24,11 +29,17 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + NULL as message 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_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 +LEFT JOIN ( + SELECT distinct fk_hydr_geometry + FROM qgep_od.hydr_geom_relation +) 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 @@ -71,8 +82,14 @@ SELECT coalesce(wn.bottom_level,0) as InvertElev, coalesce((ii.upper_elevation-wn.bottom_level),0) as MaxDepth, 0 as InitDepth, - 'FUNCTIONAL' as Shape, - 1000 as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR + CASE + WHEN hr.fk_hydr_geometry IS NOT NULL THEN 'TABULAR' + ELSE 'FUNCTIONAL' + END as Shape, + CASE + WHEN hr.fk_hydr_geometry IS NOT NULL THEN concat('storageCurve@',wn.obj_id) + ELSE '0' + END as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR 0 as CurveExponent, -- if FONCTIONAL 0 as CurveConstant, -- if FONCTIONAL 0 as SurchargeDepth, @@ -86,11 +103,17 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + NULL as message 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_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 +LEFT JOIN ( + SELECT distinct fk_hydr_geometry + 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 ( --3282 --"with_soil_passage" @@ -106,4 +129,39 @@ WHERE ii.kind IN ( --3283 --"infiltration_pipe_sections_gallery" ) AND ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); +AND status IN (6530, 6533, 8493, 6529, 6526, 7959) + +UNION ALL + +-- Storage created for the modelisation of prank weir having a H/Q curve +SELECT + wn.obj_id as Name, + coalesce(wn.bottom_level,0) as InvertElev, + coalesce((wn.backflow_level-wn.bottom_level),0) as MaxDepth, + 0 as InitDepth, + 'FUNCTIONAL' as Shape, + '0' as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR + 0 as CurveExponent, -- if FONCTIONAL + 0 as CurveConstant, -- if FONCTIONAL + 0 as SurchargeDepth, + 0 as Fevap, + NULL as Psi, + NULL as Ksat, + NULL as IMD, + ws.identifier::text as description, + 'Prank weir' as tag, + wn.situation_geometry as geom, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state, + concat(wn.obj_id, ' Storage created for the prank weir: ', pw.obj_id) as message +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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND 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) diff --git a/swmm_views/14_vw_swmm_outlets.sql b/swmm_views/14_vw_swmm_outlets.sql new file mode 100644 index 000000000..0085f012d --- /dev/null +++ b/swmm_views/14_vw_swmm_outlets.sql @@ -0,0 +1,24 @@ +CREATE OR REPLACE VIEW qgep_swmm.vw_outlets AS + +SELECT + concat('outlet@',pw.obj_id) as Name, + of.fk_wastewater_node as FromNode, -- inlet is the waternode entering the pump + of.fk_overflow_to as ToNode, -- outlet is the waternode at the top of next reach + 0 as Offset, + 'TABULAR/DEPTH' as type, + concat('prank_weir_curve@',pw.obj_id) as QTable_Qcoeff, + NULL as Qexpon, + 'NO' as Gated, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state +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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND 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 diff --git a/swmm_views/14_vw_swmm_xsections.sql b/swmm_views/14_vw_swmm_xsections.sql index c89c425fb..2d8e5123b 100644 --- a/swmm_views/14_vw_swmm_xsections.sql +++ b/swmm_views/14_vw_swmm_xsections.sql @@ -36,4 +36,30 @@ LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ne.fk_wastewater_ LEFT JOIN qgep_od.channel ch ON ch.obj_id::text = ws.obj_id::text WHERE ch.function_hierarchic = ANY (ARRAY[5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074]) -- select only operationals and "planned" -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file +AND status IN (6530, 6533, 8493, 6529, 6526, 7959) + +UNION ALL + +-- For the prank weir +SELECT + pw.obj_id as Name, + 'RECT_OPEN' as Shape, + (level_max - level_min) as Geom1, + hydraulic_overflow_length as Geom2, + NULL as Geom3, + NULL as Geom4, + NULL as Barrels, + NULL as Culvert, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state +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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND status 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 \ No newline at end of file diff --git a/swmm_views/15_vw_swmm_orifices.sql b/swmm_views/15_vw_swmm_orifices.sql new file mode 100644 index 000000000..eedd64258 --- /dev/null +++ b/swmm_views/15_vw_swmm_orifices.sql @@ -0,0 +1,12 @@ +CREATE OR REPLACE VIEW qgep_swmm.vw_orifices AS + +SELECT +NULL::text as Name, +NULL::text as FromNode, +NULL::text as ToNode, +'SIDE'::text as Type, +0::text as Offset, +0.65::text as Qcoeff, +'NO'::text as Gated, +0 ::text as CloseTime +LIMIT 0; \ No newline at end of file diff --git a/swmm_views/15_vw_swmm_weirs.sql b/swmm_views/15_vw_swmm_weirs.sql new file mode 100644 index 000000000..71bf7b97e --- /dev/null +++ b/swmm_views/15_vw_swmm_weirs.sql @@ -0,0 +1,61 @@ +CREATE OR REPLACE VIEW qgep_swmm.vw_weirs AS + +-- prank weirs without h/q relations +SELECT + pw.obj_id as Name, + of.fk_wastewater_node as FromNode, -- inlet is the waternode entering the pump + of.fk_overflow_to as ToNode, -- outlet is the waternode at the top of next reach + 'SIDEFLOW' as Type, + coalesce(wn.backflow_level,0) as CrestHt, + 3.33 as Qcoeff, + 'NO' as Gated, + 0 as EndCond, + 0 as EndCoeff, + 'YES' as Surcharge, + NULL as RoadWidth, + NULL as RoadSurf, + NULL as CoeffCurve, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state, + NULL as message +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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND 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) + +UNION ALL + +-- leapingweirs +SELECT + lw.obj_id as Name, + of.fk_wastewater_node as FromNode, -- inlet is the waternode entering the pump + of.fk_overflow_to as ToNode, -- outlet is the waternode at the top of next reach + 'SIDEFLOW' as Type, + coalesce(wn.backflow_level,0) as CrestHt, + 3.33 as Qcoeff, + 'NO' as Gated, + 0 as EndCond, + 0 as EndCoeff, + 'YES' as Surcharge, + NULL as RoadWidth, + NULL as RoadSurf, + NULL as CoeffCurve, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state, + concat('Leaping weirs are not supported by SWMM, ', lw.obj_id, 'see: https://swmm5.org/2013/07/19/leaping-weir-example-in-swmm-5-and-infoswmm-alternative/') as message +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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file diff --git a/swmm_views/16_vw_swmm_tags.sql b/swmm_views/16_vw_swmm_tags.sql index e95cc2b89..ad8ce21bf 100644 --- a/swmm_views/16_vw_swmm_tags.sql +++ b/swmm_views/16_vw_swmm_tags.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class tags --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_tags AS diff --git a/swmm_views/17_vw_swmm_curves.sql b/swmm_views/17_vw_swmm_curves.sql new file mode 100644 index 000000000..1aad88a46 --- /dev/null +++ b/swmm_views/17_vw_swmm_curves.sql @@ -0,0 +1,82 @@ +-------- +-- View for the swmm module class curves +-------- +CREATE OR REPLACE VIEW qgep_swmm.vw_curves AS + +-- Pump curves +(SELECT + concat('pump_curve@',pu.obj_id)::varchar as Name, + CASE + WHEN ROW_NUMBER () OVER (PARTITION BY pu.obj_id ORDER BY pu.obj_id, hq.altitude) = 1 + THEN 'Pump4' + ELSE NULL + END as type, + hq.altitude as XValue, + hq.flow as YValue, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state +FROM qgep_od.hq_relation hq +LEFT JOIN qgep_od.overflow_char oc ON hq.fk_overflow_characteristic = oc.obj_id +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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND 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) +AND pu.obj_id IS NOT NULL +ORDER BY pu.obj_id, hq.altitude) + +UNION ALL + +-- Prank weir curves +(SELECT + concat('prank_weir_curve@',pw.obj_id)::varchar as Name, + CASE + WHEN ROW_NUMBER () OVER (PARTITION BY pw.obj_id ORDER BY pw.obj_id, hq.altitude) = 1 + THEN 'Rating' + ELSE NULL + END as type, + hq.altitude as XValue, + hq.flow as YValue, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state +FROM qgep_od.hq_relation hq +LEFT JOIN qgep_od.overflow_char oc ON hq.fk_overflow_characteristic = oc.obj_id +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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) +AND 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) +AND pw.obj_id IS NOT NULL +ORDER BY pw.obj_id, hq.altitude) + +UNION ALL + +-- storage curves +(SELECT + concat('storageCurve@',wn.obj_id)::varchar as Name, + CASE + WHEN ROW_NUMBER () OVER (PARTITION BY wn.obj_id ORDER BY wn.obj_id, hr.water_depth) = 1 + THEN 'Storage' + ELSE NULL + END as type, + hr.water_depth as XValue, + hr.water_surface as YValue, + CASE + WHEN status IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state +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 From 34b7a3a3453a77c37c6f6b1e6bb47762f02a11af Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 11 Nov 2022 07:17:38 +0100 Subject: [PATCH 18/39] add X,Y location for raingages --- swmm_views/17_vw_swmm_symbols.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 swmm_views/17_vw_swmm_symbols.sql diff --git a/swmm_views/17_vw_swmm_symbols.sql b/swmm_views/17_vw_swmm_symbols.sql new file mode 100644 index 000000000..9306dce68 --- /dev/null +++ b/swmm_views/17_vw_swmm_symbols.sql @@ -0,0 +1,12 @@ +-------- +-- View for the swmm module class symbols (rain gages locations) +-- - This view depends on qgep_swmm.vw_raingages +-------- +CREATE OR REPLACE VIEW qgep_swmm.vw_symbols AS + +SELECT + Name as Gage, + st_x(geom) as Xcoord, + st_y(geom) as Ycoord, + state as state +FROM qgep_swmm.vw_raingages From c183f4ffab6731613b09575262e6a6a083326742 Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 11 Nov 2022 08:07:08 +0100 Subject: [PATCH 19/39] change name of the coverages --- swmm_views/09_vw_swmm_subcatchments.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index a6a5c4882..9808a9f5b 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -204,11 +204,11 @@ WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnecte -- creates coverages CREATE OR REPLACE VIEW qgep_swmm.vw_coverages AS SELECT - replace(ca.obj_id, ' ', '_') as Subcatchment, + sub.Name as Subcatchment, pzk.value_en as landUse, - round((st_area(st_intersection(ca.perimeter_geometry, pz.perimeter_geometry))/st_area(ca.perimeter_geometry))::numeric,2)*100 as percent -FROM qgep_od.catchment_area ca, qgep_od.planning_zone pz + round((st_area(st_intersection(sub.geom, pz.perimeter_geometry))/st_area(sub.geom))::numeric,2)*100 as percent +FROM qgep_swmm.vw_subcatchments sub, qgep_od.planning_zone pz LEFT JOIN qgep_vl.planning_zone_kind pzk on pz.kind = pzk.code -WHERE st_intersects(ca.perimeter_geometry, pz.perimeter_geometry) -AND st_isvalid(ca.perimeter_geometry) AND st_isvalid(pz.perimeter_geometry) -ORDER BY ca.obj_id, percent DESC; +WHERE st_intersects(sub.geom, pz.perimeter_geometry) +AND st_isvalid(sub.geom) AND st_isvalid(pz.perimeter_geometry) +ORDER BY sub.Name, percent DESC; From c1a242fbe2d2dbea5b06fb153d682f627b66c189 Mon Sep 17 00:00:00 2001 From: tproduit Date: Fri, 11 Nov 2022 08:23:27 +0100 Subject: [PATCH 20/39] Update 14_vw_swmm_xsections.sql --- swmm_views/14_vw_swmm_xsections.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/swmm_views/14_vw_swmm_xsections.sql b/swmm_views/14_vw_swmm_xsections.sql index b7a8f8e2b..1660ebad2 100644 --- a/swmm_views/14_vw_swmm_xsections.sql +++ b/swmm_views/14_vw_swmm_xsections.sql @@ -15,13 +15,13 @@ SELECT DISTINCT WHEN pp.profile_type = 3354 THEN 'PARABOLIC' -- open ELSE 'CIRCULAR' END as Shape, - --ROMA: Geom1 = height -> used for all the profile types + --Geom1 = height -> used for all the profile types CASE WHEN re.clear_height = 0 THEN 0.1 WHEN re.clear_height IS NULL THEN 0.1 ELSE re.clear_height/1000::float -- [mm] to [m] END as Geom1, - --ROMA: Geom2 = width -> needed for profile rect_closed,arch and parabolic + --Geom2 = width -> needed for profile rect_closed,arch and parabolic CASE WHEN pp.profile_type IN (3352,3353,3354) THEN CASE WHEN pp.height_width_ratio IS NOT NULL THEN CASE @@ -34,7 +34,7 @@ SELECT DISTINCT END ELSE NULL END as Geom2, - --ROMA: Geom3 = code -> used only for arch profile, but this code value is nowhere to be set in the QGEP model + --Geom3 = code -> used only for arch profile, but this code value is nowhere to be set in the QGEP model 0 as Geom3, 0 as Geom4, 1 as Barrels, @@ -43,7 +43,7 @@ SELECT DISTINCT WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - --ROMA: message give details about the profile type, height availability, width availability if needed and code availablitity if needed. To much details? + --message give details about the profile type, height availability, width availability if needed and code availablitity if needed. To much details? CASE WHEN pp.profile_type = 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') @@ -92,4 +92,4 @@ LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ne.fk_wastewater_ LEFT JOIN qgep_od.channel ch ON ch.obj_id::text = ws.obj_id::text WHERE ch.function_hierarchic = ANY (ARRAY[5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074]) -- select only operationals and "planned" -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file +AND status IN (6530, 6533, 8493, 6529, 6526, 7959); From d6701c2c69b11306e1e7d8b20bf5131f51e926d0 Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 11 Nov 2022 10:00:06 +0100 Subject: [PATCH 21/39] add delta file for new attributes --- ...ta_1.5.X_add_reach_default_coefficient_friction.sql | 2 ++ ...on.sql => delta_1.5.X_add_reach_hydraulic_load.sql} | 0 delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql | 10 ++++++++++ swmm_views/02_vw_swmm_junctions.sql | 1 - swmm_views/03_vw_swmm_aquifers.sql | 1 - swmm_views/04_vw_swmm_conduits.sql | 3 +-- .../{15_vw_swmm_weirs.sql => 16_vw_swmm_weirs.sql} | 0 ..._vw_swmm_xsections.sql => 18_vw_swmm_xsections.sql} | 0 ...swmm_coordinates.sql => 19_vw_swmm_coordinates.sql} | 0 .../{16_vw_swmm_tags.sql => 20_vw_swmm_tags.sql} | 0 .../{17_vw_swmm_symbols.sql => 21_vw_swmm_symbols.sql} | 0 11 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 delta/delta_1.5.X_add_reach_default_coefficient_friction.sql rename delta/{delta_1.X.X_tbl_swmm_coefficient_friction.sql => delta_1.5.X_add_reach_hydraulic_load.sql} (100%) create mode 100644 delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql rename swmm_views/{15_vw_swmm_weirs.sql => 16_vw_swmm_weirs.sql} (100%) rename swmm_views/{14_vw_swmm_xsections.sql => 18_vw_swmm_xsections.sql} (100%) rename swmm_views/{15_vw_swmm_coordinates.sql => 19_vw_swmm_coordinates.sql} (100%) rename swmm_views/{16_vw_swmm_tags.sql => 20_vw_swmm_tags.sql} (100%) rename swmm_views/{17_vw_swmm_symbols.sql => 21_vw_swmm_symbols.sql} (100%) diff --git a/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql b/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql new file mode 100644 index 000000000..4b142562a --- /dev/null +++ b/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql @@ -0,0 +1,2 @@ +ALTER TABLE qgep_od.reach ADD COLUMN default_coefficient_of_friction smallint ; +COMMENT ON COLUMN qgep_od.reach.default_coefficient_of_friction IS 'yyy http://www.fsl.orst.edu/geowater/FX3/help/8_Hydraulic_Reference/Mannings_n_Tables.htm / (1 / N_Manning) value between 0 and 999'; diff --git a/delta/delta_1.X.X_tbl_swmm_coefficient_friction.sql b/delta/delta_1.5.X_add_reach_hydraulic_load.sql similarity index 100% rename from delta/delta_1.X.X_tbl_swmm_coefficient_friction.sql rename to delta/delta_1.5.X_add_reach_hydraulic_load.sql diff --git a/delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql b/delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql new file mode 100644 index 000000000..252769518 --- /dev/null +++ b/delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql @@ -0,0 +1,10 @@ +CREATE TABLE qgep_swmm.reach_coefficient_of_friction (fk_material integer, coefficient_of_friction smallint); +ALTER TABLE qgep_swmm.reach_coefficient_of_friction ADD CONSTRAINT pkey_qgep_vl_reach_coefficient_of_friction_id PRIMARY KEY (fk_material); +INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) SELECT vsacode FROM qgep_vl.reach_material; +UPDATE qgep_swmm.reach_coefficient_of_friction SET coefficient_of_friction = (CASE WHEN fk_material IN (5381,5081,3016) THEN 100 + WHEN fk_material IN (2754,3638,3639,3640,3641,3256,147,148,3648,5079,5080,153,2762) THEN 83 + WHEN fk_material IN (2755) THEN 67 + WHEN fk_material IN (5076,5077,5078,5382) THEN 111 + WHEN fk_material IN (3654) THEN 91 + WHEN fk_material IN (154,2761) THEN 71 + ELSE 100 END); \ No newline at end of file diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 24bd33dbb..992be3a39 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class junction --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_junctions AS diff --git a/swmm_views/03_vw_swmm_aquifers.sql b/swmm_views/03_vw_swmm_aquifers.sql index 7b8cafa86..9b2edb5a5 100644 --- a/swmm_views/03_vw_swmm_aquifers.sql +++ b/swmm_views/03_vw_swmm_aquifers.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class aquifiers --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_aquifers AS diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 3d58cf9df..4beaa12fa 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class conduits --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_conduits AS @@ -59,7 +58,7 @@ SELECT WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': The default value stored in qgep_swmm.reach_coefficient_of_friction is used') ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') END - ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') + -- TODO ROMA: ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') WHEN to_wn.obj_id IS NULL THEN concat(re.obj_id, ' is a blind connection, the destionation node must be edited in SWMM.') WHEN from_wn.obj_id IS NULL AND to_wn.obj_id IS NOT NULL THEN concat(re.obj_id, ' has no from node, a junction is automatically created for the export.') END AS message diff --git a/swmm_views/15_vw_swmm_weirs.sql b/swmm_views/16_vw_swmm_weirs.sql similarity index 100% rename from swmm_views/15_vw_swmm_weirs.sql rename to swmm_views/16_vw_swmm_weirs.sql diff --git a/swmm_views/14_vw_swmm_xsections.sql b/swmm_views/18_vw_swmm_xsections.sql similarity index 100% rename from swmm_views/14_vw_swmm_xsections.sql rename to swmm_views/18_vw_swmm_xsections.sql diff --git a/swmm_views/15_vw_swmm_coordinates.sql b/swmm_views/19_vw_swmm_coordinates.sql similarity index 100% rename from swmm_views/15_vw_swmm_coordinates.sql rename to swmm_views/19_vw_swmm_coordinates.sql diff --git a/swmm_views/16_vw_swmm_tags.sql b/swmm_views/20_vw_swmm_tags.sql similarity index 100% rename from swmm_views/16_vw_swmm_tags.sql rename to swmm_views/20_vw_swmm_tags.sql diff --git a/swmm_views/17_vw_swmm_symbols.sql b/swmm_views/21_vw_swmm_symbols.sql similarity index 100% rename from swmm_views/17_vw_swmm_symbols.sql rename to swmm_views/21_vw_swmm_symbols.sql From 9121ba4d9ba5943da2b694ec7c930178cd9e5737 Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 11 Nov 2022 13:00:03 +0100 Subject: [PATCH 22/39] separate views --- .../delta_1.5.X_add_reach_hydraulic_load.sql | 12 +- swmm_views/05_vw_swmm_dividers.sql | 1 - swmm_views/06_vw_swmm_landuses.sql | 1 - swmm_views/08_vw_swmm_outfalls.sql | 1 - swmm_views/09_vw_swmm_subcatchments.sql | 252 +----------------- swmm_views/10_vw_swmm_subareas.sql | 59 ++++ swmm_views/11_vw_swmm_dwf.sql | 99 +++++++ swmm_views/12_vw_swmm_raingages.sql | 45 ++++ swmm_views/13_vw_swmm_infiltrations.sql | 34 +++ swmm_views/14_vw_swmm_coverages.sql | 11 + ...m_vertices.sql => 15_vw_swmm_vertices.sql} | 0 ...vw_swmm_pumps.sql => 16_vw_swmm_pumps.sql} | 0 ...m_polygons.sql => 17_vw_swmm_polygons.sql} | 0 ...m_storages.sql => 18_vw_swmm_storages.sql} | 0 ...wmm_outlets.sql => 19_vw_swmm_outlets.sql} | 0 ...m_orifices.sql => 20_vw_swmm_orifices.sql} | 0 ...vw_swmm_weirs.sql => 21_vw_swmm_weirs.sql} | 0 ..._swmm_curves.sql => 22_vw_swmm_curves.sql} | 0 ...xsections.sql => 23_vw_swmm_xsections.sql} | 1 - ...dinates.sql => 24_vw_swmm_coordinates.sql} | 1 - ...0_vw_swmm_tags.sql => 25_vw_swmm_tags.sql} | 0 ...wmm_symbols.sql => 26_vw_swmm_symbols.sql} | 0 22 files changed, 251 insertions(+), 266 deletions(-) create mode 100644 swmm_views/10_vw_swmm_subareas.sql create mode 100644 swmm_views/11_vw_swmm_dwf.sql create mode 100644 swmm_views/12_vw_swmm_raingages.sql create mode 100644 swmm_views/13_vw_swmm_infiltrations.sql create mode 100644 swmm_views/14_vw_swmm_coverages.sql rename swmm_views/{10_vw_swmm_vertices.sql => 15_vw_swmm_vertices.sql} (100%) rename swmm_views/{11_vw_swmm_pumps.sql => 16_vw_swmm_pumps.sql} (100%) rename swmm_views/{12_vw_swmm_polygons.sql => 17_vw_swmm_polygons.sql} (100%) rename swmm_views/{13_vw_swmm_storages.sql => 18_vw_swmm_storages.sql} (100%) rename swmm_views/{14_vw_swmm_outlets.sql => 19_vw_swmm_outlets.sql} (100%) rename swmm_views/{15_vw_swmm_orifices.sql => 20_vw_swmm_orifices.sql} (100%) rename swmm_views/{16_vw_swmm_weirs.sql => 21_vw_swmm_weirs.sql} (100%) rename swmm_views/{17_vw_swmm_curves.sql => 22_vw_swmm_curves.sql} (100%) rename swmm_views/{18_vw_swmm_xsections.sql => 23_vw_swmm_xsections.sql} (99%) rename swmm_views/{19_vw_swmm_coordinates.sql => 24_vw_swmm_coordinates.sql} (96%) rename swmm_views/{20_vw_swmm_tags.sql => 25_vw_swmm_tags.sql} (100%) rename swmm_views/{21_vw_swmm_symbols.sql => 26_vw_swmm_symbols.sql} (100%) diff --git a/delta/delta_1.5.X_add_reach_hydraulic_load.sql b/delta/delta_1.5.X_add_reach_hydraulic_load.sql index 252769518..8307b0ac6 100644 --- a/delta/delta_1.5.X_add_reach_hydraulic_load.sql +++ b/delta/delta_1.5.X_add_reach_hydraulic_load.sql @@ -1,10 +1,2 @@ -CREATE TABLE qgep_swmm.reach_coefficient_of_friction (fk_material integer, coefficient_of_friction smallint); -ALTER TABLE qgep_swmm.reach_coefficient_of_friction ADD CONSTRAINT pkey_qgep_vl_reach_coefficient_of_friction_id PRIMARY KEY (fk_material); -INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) SELECT vsacode FROM qgep_vl.reach_material; -UPDATE qgep_swmm.reach_coefficient_of_friction SET coefficient_of_friction = (CASE WHEN fk_material IN (5381,5081,3016) THEN 100 - WHEN fk_material IN (2754,3638,3639,3640,3641,3256,147,148,3648,5079,5080,153,2762) THEN 83 - WHEN fk_material IN (2755) THEN 67 - WHEN fk_material IN (5076,5077,5078,5382) THEN 111 - WHEN fk_material IN (3654) THEN 91 - WHEN fk_material IN (154,2761) THEN 71 - ELSE 100 END); \ No newline at end of file +ALTER TABLE qgep_od.reach ADD COLUMN hydraulic_load decimal(7,3) ; +COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; \ No newline at end of file diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index 922ad0a05..e82c88720 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class dividers --- 20190329 qgep code sprint SB, TP -- Question attribute Diverted Link: Name of link which receives the diverted flow. overflow > fk_overflow_to CREATE OR REPLACE VIEW qgep_swmm.vw_dividers AS diff --git a/swmm_views/06_vw_swmm_landuses.sql b/swmm_views/06_vw_swmm_landuses.sql index 4bc0961ab..c7a3257e5 100644 --- a/swmm_views/06_vw_swmm_landuses.sql +++ b/swmm_views/06_vw_swmm_landuses.sql @@ -1,6 +1,5 @@ ------- -- View for the swmm module class landuses --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_landuses AS SELECT diff --git a/swmm_views/08_vw_swmm_outfalls.sql b/swmm_views/08_vw_swmm_outfalls.sql index cd1abb643..aa42cda1f 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class outfalls --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_outfalls AS diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index cb0ed83c6..b4dbaf331 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -1,7 +1,6 @@ -------- -- View for the swmm module class subcatchments --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_subcatchments AS @@ -76,253 +75,4 @@ FROM ( 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 -) as ca; - - --- Creates subarea related to the subcatchment -CREATE OR REPLACE VIEW qgep_swmm.vw_subareas AS -SELECT - concat(replace(ca.obj_id, ' ', '_'), '_', state) as Subcatchment, - 0.01 as NImperv, -- default value, Manning's n for overland flow over the impervious portion of the subcatchment - 0.1 as NPerv,-- default value, Manning's n for overland flow over the pervious portion of the subcatchment - CASE - WHEN surface_storage IS NOT NULL THEN surface_storage - ELSE 0.05 -- default value - END as SImperv,-- Depth of depression storage on the impervious portion of the subcatchment (inches or millimeters) - CASE - WHEN surface_storage IS NOT NULL THEN surface_storage - ELSE 0.05 -- default value - END as SPerv,-- Depth of depression storage on the pervious portion of the subcatchment (inches or millimeters) - 25 as PctZero,-- default value, Percent of the impervious area with no depression storage. - 'OUTLET'::varchar as RouteTo, - NULL::float as PctRouted, - ca.identifier || ', ' || ca.remark as description, - ca.obj_id::varchar as tag, - state as state, - CASE - WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' - ELSE 'secondary' - END as hierarchy, - 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 -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 -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 -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 -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 -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 -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 -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 -WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments -) as ca; - --- Creates Dry Weather Flow related to the catchment area -CREATE OR REPLACE VIEW qgep_swmm.vw_dwf AS -SELECT - CASE - WHEN type_ca = 'rw_current' THEN fk_wastewater_networkelement_rw_current - WHEN type_ca = 'rw_planned' THEN fk_wastewater_networkelement_rw_planned - WHEN type_ca = 'ww_current' THEN fk_wastewater_networkelement_ww_current - WHEN type_ca = 'ww_planned' THEN fk_wastewater_networkelement_ww_planned - END as Node, -- id of the junction - 'FLOW'::varchar as Constituent, - CASE - WHEN fk_wastewater_networkelement_ww_current is not null - THEN - CASE - WHEN waste_water_production_current IS NOT NULL THEN waste_water_production_current - ELSE - CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) - ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) - END - END - WHEN fk_wastewater_networkelement_ww_planned is not null - THEN - CASE - WHEN waste_water_production_planned IS NOT NULL THEN waste_water_production_planned - ELSE - CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_planned,0) * surface_area * 160 / (24 * 60 * 60) - ELSE coalesce(population_density_planned,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) - END - END - WHEN fk_wastewater_networkelement_rw_current is not null - THEN 0 - WHEN fk_wastewater_networkelement_rw_planned is not null - THEN 0 - END as Baseline, -- 160 Litre / inhabitant /day - CASE - WHEN fk_wastewater_networkelement_ww_current is not null - THEN - CASE - WHEN waste_water_production_current IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_current') - ELSE - CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day') - ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day') - END - END - WHEN fk_wastewater_networkelement_ww_planned is not null - THEN - CASE - WHEN waste_water_production_planned IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_planned') - ELSE - CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day') - ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day') - END - END - WHEN fk_wastewater_networkelement_rw_current is not null - THEN '' - WHEN fk_wastewater_networkelement_rw_planned is not null - THEN '' - END as message, - 'dailyPatternDWF'::varchar as Patterns, - state as state, - CASE - WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' - ELSE 'secondary' - END as hierarchy, - wn_obj_id as obj_id -FROM -( -SELECT ca.*,'current' as state, 'rw_current' as type_ca -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 -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 -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 -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 -FROM qgep_od.catchment_area as ca -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 -FROM qgep_od.catchment_area as ca -WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments -) as ca; - --- Creates a default raingage for each subcatchment -CREATE OR REPLACE VIEW qgep_swmm.vw_raingages AS -SELECT - ('raingage@' || replace(ca.obj_id, ' ', '_'))::varchar as Name, - 'INTENSITY'::varchar as Format, - '0:15'::varchar as Interval, - '1.0'::varchar as SCF, - 'TIMESERIES default_qgep_raingage_timeserie'::varchar as Source, - st_centroid(perimeter_geometry)::geometry(Point, %(SRID)s) as geom, - state, - CASE - WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' - ELSE 'secondary' - END as hierarchy, - wn_obj_id as obj_id -FROM -( -SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 -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 -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 -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 -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 -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 -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 -WHERE fk_wastewater_networkelement_ww_planned IS NOT NULL -- to avoid unconnected catchments -) as ca; - --- Creates default infiltration for each subcatchment -CREATE OR REPLACE VIEW qgep_swmm.vw_infiltration AS -SELECT - CASE - WHEN state = 'current' THEN concat(replace(ca.obj_id, ' ', '_'), '_', 'rw_current') - WHEN state = 'planned' THEN concat(replace(ca.obj_id, ' ', '_'), '_', 'rw_planned') - END as Subcatchment, - 3 as MaxRate, - 0.5 as MinRate, - 4 as Decay, - 7 as DryTime, - 0 as MaxInfil, - state, - CASE - WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' - ELSE 'secondary' - END as hierarchy, - wn_obj_id as obj_id -FROM -( -SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 -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 -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 -WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments -) as ca; - - --- creates coverages -CREATE OR REPLACE VIEW qgep_swmm.vw_coverages AS -SELECT - sub.Name as Subcatchment, - pzk.value_en as landUse, - round((st_area(st_intersection(sub.geom, pz.perimeter_geometry))/st_area(sub.geom))::numeric,2)*100 as percent -FROM qgep_swmm.vw_subcatchments sub, qgep_od.planning_zone pz -LEFT JOIN qgep_vl.planning_zone_kind pzk on pz.kind = pzk.code -WHERE st_intersects(sub.geom, pz.perimeter_geometry) -AND st_isvalid(sub.geom) AND st_isvalid(pz.perimeter_geometry) -ORDER BY sub.Name, percent DESC; +) as ca; \ No newline at end of file diff --git a/swmm_views/10_vw_swmm_subareas.sql b/swmm_views/10_vw_swmm_subareas.sql new file mode 100644 index 000000000..546ee7e39 --- /dev/null +++ b/swmm_views/10_vw_swmm_subareas.sql @@ -0,0 +1,59 @@ +-- Creates subarea related to the subcatchment +CREATE OR REPLACE VIEW qgep_swmm.vw_subareas AS +SELECT + concat(replace(ca.obj_id, ' ', '_'), '_', state) as Subcatchment, + 0.01 as NImperv, -- default value, Manning's n for overland flow over the impervious portion of the subcatchment + 0.1 as NPerv,-- default value, Manning's n for overland flow over the pervious portion of the subcatchment + CASE + WHEN surface_storage IS NOT NULL THEN surface_storage + ELSE 0.05 -- default value + END as SImperv,-- Depth of depression storage on the impervious portion of the subcatchment (inches or millimeters) + CASE + WHEN surface_storage IS NOT NULL THEN surface_storage + ELSE 0.05 -- default value + END as SPerv,-- Depth of depression storage on the pervious portion of the subcatchment (inches or millimeters) + 25 as PctZero,-- default value, Percent of the impervious area with no depression storage. + 'OUTLET'::varchar as RouteTo, + NULL::float as PctRouted, + ca.identifier || ', ' || ca.remark as description, + ca.obj_id::varchar as tag, + state as state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + 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 +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 +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 +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 +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 +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 +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 +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 +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 new file mode 100644 index 000000000..09b284e58 --- /dev/null +++ b/swmm_views/11_vw_swmm_dwf.sql @@ -0,0 +1,99 @@ +-- Creates Dry Weather Flow related to the catchment area +CREATE OR REPLACE VIEW qgep_swmm.vw_dwf AS +SELECT + CASE + WHEN type_ca = 'rw_current' THEN fk_wastewater_networkelement_rw_current + WHEN type_ca = 'rw_planned' THEN fk_wastewater_networkelement_rw_planned + WHEN type_ca = 'ww_current' THEN fk_wastewater_networkelement_ww_current + WHEN type_ca = 'ww_planned' THEN fk_wastewater_networkelement_ww_planned + END as Node, -- id of the junction + 'FLOW'::varchar as Constituent, + CASE + WHEN fk_wastewater_networkelement_ww_current is not null + THEN + CASE + WHEN waste_water_production_current IS NOT NULL THEN waste_water_production_current + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + END + END + WHEN fk_wastewater_networkelement_ww_planned is not null + THEN + CASE + WHEN waste_water_production_planned IS NOT NULL THEN waste_water_production_planned + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_planned,0) * surface_area * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_planned,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + END + END + WHEN fk_wastewater_networkelement_rw_current is not null + THEN 0 + WHEN fk_wastewater_networkelement_rw_planned is not null + THEN 0 + END as Baseline, -- 160 Litre / inhabitant /day + CASE + WHEN fk_wastewater_networkelement_ww_current is not null + THEN + CASE + WHEN waste_water_production_current IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_current') + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day') + ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day') + END + END + WHEN fk_wastewater_networkelement_ww_planned is not null + THEN + CASE + WHEN waste_water_production_planned IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_planned') + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day') + ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day') + END + END + WHEN fk_wastewater_networkelement_rw_current is not null + THEN '' + WHEN fk_wastewater_networkelement_rw_planned is not null + THEN '' + END as message, + 'dailyPatternDWF'::varchar as Patterns, + state as state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + 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 +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 +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 +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 +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 +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 +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 +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 +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 new file mode 100644 index 000000000..80ae0133b --- /dev/null +++ b/swmm_views/12_vw_swmm_raingages.sql @@ -0,0 +1,45 @@ +-- Creates a default raingage for each subcatchment +CREATE OR REPLACE VIEW qgep_swmm.vw_raingages AS +SELECT + ('raingage@' || replace(ca.obj_id, ' ', '_'))::varchar as Name, + 'INTENSITY'::varchar as Format, + '0:15'::varchar as Interval, + '1.0'::varchar as SCF, + 'TIMESERIES default_qgep_raingage_timeserie'::varchar as Source, + st_centroid(perimeter_geometry)::geometry(Point, %(SRID)s) as geom, + state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id +FROM +( +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 +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 +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 +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 +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 +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 +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 +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 new file mode 100644 index 000000000..fd319c850 --- /dev/null +++ b/swmm_views/13_vw_swmm_infiltrations.sql @@ -0,0 +1,34 @@ +-- Creates default infiltration for each subcatchment +CREATE OR REPLACE VIEW qgep_swmm.vw_infiltration AS +SELECT + CASE + WHEN state = 'current' THEN concat(replace(ca.obj_id, ' ', '_'), '_', 'rw_current') + WHEN state = 'planned' THEN concat(replace(ca.obj_id, ' ', '_'), '_', 'rw_planned') + END as Subcatchment, + 3 as MaxRate, + 0.5 as MinRate, + 4 as Decay, + 7 as DryTime, + 0 as MaxInfil, + state, + CASE + WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn_obj_id as obj_id +FROM +( +SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, ws._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 +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 +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 +WHERE fk_wastewater_networkelement_rw_planned IS NOT NULL -- to avoid unconnected catchments +) as ca; diff --git a/swmm_views/14_vw_swmm_coverages.sql b/swmm_views/14_vw_swmm_coverages.sql new file mode 100644 index 000000000..ff16eab00 --- /dev/null +++ b/swmm_views/14_vw_swmm_coverages.sql @@ -0,0 +1,11 @@ +-- creates coverages +CREATE OR REPLACE VIEW qgep_swmm.vw_coverages AS +SELECT + sub.Name as Subcatchment, + pzk.value_en as landUse, + round((st_area(st_intersection(sub.geom, pz.perimeter_geometry))/st_area(sub.geom))::numeric,2)*100 as percent +FROM qgep_swmm.vw_subcatchments sub, qgep_od.planning_zone pz +LEFT JOIN qgep_vl.planning_zone_kind pzk on pz.kind = pzk.code +WHERE st_intersects(sub.geom, pz.perimeter_geometry) +AND st_isvalid(sub.geom) AND st_isvalid(pz.perimeter_geometry) +ORDER BY sub.Name, percent DESC; diff --git a/swmm_views/10_vw_swmm_vertices.sql b/swmm_views/15_vw_swmm_vertices.sql similarity index 100% rename from swmm_views/10_vw_swmm_vertices.sql rename to swmm_views/15_vw_swmm_vertices.sql diff --git a/swmm_views/11_vw_swmm_pumps.sql b/swmm_views/16_vw_swmm_pumps.sql similarity index 100% rename from swmm_views/11_vw_swmm_pumps.sql rename to swmm_views/16_vw_swmm_pumps.sql diff --git a/swmm_views/12_vw_swmm_polygons.sql b/swmm_views/17_vw_swmm_polygons.sql similarity index 100% rename from swmm_views/12_vw_swmm_polygons.sql rename to swmm_views/17_vw_swmm_polygons.sql diff --git a/swmm_views/13_vw_swmm_storages.sql b/swmm_views/18_vw_swmm_storages.sql similarity index 100% rename from swmm_views/13_vw_swmm_storages.sql rename to swmm_views/18_vw_swmm_storages.sql diff --git a/swmm_views/14_vw_swmm_outlets.sql b/swmm_views/19_vw_swmm_outlets.sql similarity index 100% rename from swmm_views/14_vw_swmm_outlets.sql rename to swmm_views/19_vw_swmm_outlets.sql diff --git a/swmm_views/15_vw_swmm_orifices.sql b/swmm_views/20_vw_swmm_orifices.sql similarity index 100% rename from swmm_views/15_vw_swmm_orifices.sql rename to swmm_views/20_vw_swmm_orifices.sql diff --git a/swmm_views/16_vw_swmm_weirs.sql b/swmm_views/21_vw_swmm_weirs.sql similarity index 100% rename from swmm_views/16_vw_swmm_weirs.sql rename to swmm_views/21_vw_swmm_weirs.sql diff --git a/swmm_views/17_vw_swmm_curves.sql b/swmm_views/22_vw_swmm_curves.sql similarity index 100% rename from swmm_views/17_vw_swmm_curves.sql rename to swmm_views/22_vw_swmm_curves.sql diff --git a/swmm_views/18_vw_swmm_xsections.sql b/swmm_views/23_vw_swmm_xsections.sql similarity index 99% rename from swmm_views/18_vw_swmm_xsections.sql rename to swmm_views/23_vw_swmm_xsections.sql index 60f7e5cae..18a79d596 100644 --- a/swmm_views/18_vw_swmm_xsections.sql +++ b/swmm_views/23_vw_swmm_xsections.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class xsections --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_xsections AS diff --git a/swmm_views/19_vw_swmm_coordinates.sql b/swmm_views/24_vw_swmm_coordinates.sql similarity index 96% rename from swmm_views/19_vw_swmm_coordinates.sql rename to swmm_views/24_vw_swmm_coordinates.sql index 372ea1ce7..2e7970d2f 100644 --- a/swmm_views/19_vw_swmm_coordinates.sql +++ b/swmm_views/24_vw_swmm_coordinates.sql @@ -1,6 +1,5 @@ -------- -- View for the swmm module class coordinates --- 20190329 qgep code sprint SB, TP -------- CREATE OR REPLACE VIEW qgep_swmm.vw_coordinates AS diff --git a/swmm_views/20_vw_swmm_tags.sql b/swmm_views/25_vw_swmm_tags.sql similarity index 100% rename from swmm_views/20_vw_swmm_tags.sql rename to swmm_views/25_vw_swmm_tags.sql diff --git a/swmm_views/21_vw_swmm_symbols.sql b/swmm_views/26_vw_swmm_symbols.sql similarity index 100% rename from swmm_views/21_vw_swmm_symbols.sql rename to swmm_views/26_vw_swmm_symbols.sql From 39de29b35f20e2b296f4bf89bd525556809a0653 Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 11 Nov 2022 14:42:52 +0100 Subject: [PATCH 23/39] dividers --- swmm_views/05_vw_swmm_dividers.sql | 31 +++++++++++++++------------ swmm_views/14_vw_swmm_coverages.sql | 3 +++ swmm_views/15_vw_swmm_vertices.sql | 2 +- swmm_views/17_vw_swmm_polygons.sql | 2 +- swmm_views/18_vw_swmm_storages.sql | 13 +++++++---- swmm_views/19_vw_swmm_outlets.sql | 10 ++++++--- swmm_views/20_vw_swmm_orifices.sql | 5 ++++- swmm_views/21_vw_swmm_weirs.sql | 16 ++++++++++---- swmm_views/22_vw_swmm_curves.sql | 27 +++++++++++++++++------ swmm_views/23_vw_swmm_xsections.sql | 13 +++++++---- swmm_views/24_vw_swmm_coordinates.sql | 25 ++++++++++++++------- swmm_views/25_vw_swmm_tags.sql | 7 ++++++ swmm_views/26_vw_swmm_symbols.sql | 4 +++- 13 files changed, 110 insertions(+), 48 deletions(-) diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index e82c88720..add20407f 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -5,13 +5,14 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_dividers AS SELECT ma.obj_id as Name, - st_x(wn.situation_geometry) as X_coordinate, - st_y(wn.situation_geometry) as Y_coordinate, - ws.identifier as description, - CONCAT_WS(',', 'manhole', mf.value_en) as tag, - wn.bottom_level as invert_elev, - (co.level-wn.bottom_level) as max_depth, - '???' as diverted_link, + wn.bottom_level as Elevation, + NULL as diverted_link, + 'CUTOFF' as Type, + 0 as CutoffFlow, + 0 as MaxDepth, + 0 as InitialDepth, + 0 as SurchargeDepth, + 0 as PondedArea, CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' @@ -34,13 +35,15 @@ UNION ALL SELECT ss.obj_id as Name, - st_x(wn.situation_geometry) as X_coordinate, - st_y(wn.situation_geometry) as Y_coordinate, - ws.identifier as description, - CONCAT_WS(',','special_structure', ssf.value_en) as tag, - wn.bottom_level as invert_elev, - (co.level-wn.bottom_level) as max_depth, - '???' as diverted_link, + wn.bottom_level as Elevation, + NULL as diverted_link, + 'CUTOFF' as Type, + 0 as CutoffFlow, + 0 as MaxDepth, + 0 as InitialDepth, + 0 as SurchargeDepth, + 0 as PondedArea, + wn.situation_geometry as geom, CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' diff --git a/swmm_views/14_vw_swmm_coverages.sql b/swmm_views/14_vw_swmm_coverages.sql index ff16eab00..4a7603ffd 100644 --- a/swmm_views/14_vw_swmm_coverages.sql +++ b/swmm_views/14_vw_swmm_coverages.sql @@ -1,4 +1,7 @@ +----------------------------------------- -- creates coverages +-- - Depends on qgep_swmm.subcatchments +----------------------------------------- CREATE OR REPLACE VIEW qgep_swmm.vw_coverages AS SELECT sub.Name as Subcatchment, diff --git a/swmm_views/15_vw_swmm_vertices.sql b/swmm_views/15_vw_swmm_vertices.sql index 390592fbb..509e07da9 100644 --- a/swmm_views/15_vw_swmm_vertices.sql +++ b/swmm_views/15_vw_swmm_vertices.sql @@ -1,6 +1,6 @@ -------- -- View for the swmm module class vertices --- 20190329 qgep code sprint SB, TP +-- - Depends on qgep_swmm.vw_conduits -------- CREATE OR REPLACE VIEW qgep_swmm.vw_vertices AS diff --git a/swmm_views/17_vw_swmm_polygons.sql b/swmm_views/17_vw_swmm_polygons.sql index 9a0d0a160..46ee8c6fd 100644 --- a/swmm_views/17_vw_swmm_polygons.sql +++ b/swmm_views/17_vw_swmm_polygons.sql @@ -1,6 +1,6 @@ -------- -- View for the swmm module class polygons --- 20190329 qgep code sprint SB, TP +-- - Depends on qgep_swmm.vw_subcatchments -------- CREATE OR REPLACE VIEW qgep_swmm.vw_polygons AS diff --git a/swmm_views/18_vw_swmm_storages.sql b/swmm_views/18_vw_swmm_storages.sql index 0531e46aa..fccc67a9e 100644 --- a/swmm_views/18_vw_swmm_storages.sql +++ b/swmm_views/18_vw_swmm_storages.sql @@ -80,7 +80,9 @@ WHERE ss.function IN ( -- must be the same list in vw_swmm_junctions -- 2745, --"vortex_manhole" ) AND status IN (6530, 6533, 8493, 6529, 6526, 7959) + UNION ALL + SELECT wn.obj_id as Name, coalesce(wn.bottom_level,0) as InvertElev, @@ -112,7 +114,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - ws.obj_id as ws_obj_id, + wn.obj_id as obj_id, NULL as message FROM qgep_od.infiltration_installation as ii LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ii.obj_id::text @@ -137,7 +139,6 @@ WHERE ii.kind IN ( --278 --"adsorbing_well" --3283 --"infiltration_pipe_sections_gallery" ) - AND status IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -164,13 +165,17 @@ SELECT WHEN status 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' + ELSE 'secondary' + END as hierarchy, + wn.obj_id as obj_id, concat(wn.obj_id, ' Storage created for the prank weir: ', pw.obj_id) as message 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +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) diff --git a/swmm_views/19_vw_swmm_outlets.sql b/swmm_views/19_vw_swmm_outlets.sql index 0085f012d..73f369514 100644 --- a/swmm_views/19_vw_swmm_outlets.sql +++ b/swmm_views/19_vw_swmm_outlets.sql @@ -12,13 +12,17 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +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 diff --git a/swmm_views/20_vw_swmm_orifices.sql b/swmm_views/20_vw_swmm_orifices.sql index eedd64258..0fa173280 100644 --- a/swmm_views/20_vw_swmm_orifices.sql +++ b/swmm_views/20_vw_swmm_orifices.sql @@ -8,5 +8,8 @@ NULL::text as ToNode, 0::text as Offset, 0.65::text as Qcoeff, 'NO'::text as Gated, -0 ::text as CloseTime +0 ::text as CloseTime, +NULL::text as state, +NULL::text as hierarchy, +NULL::text as obj_id LIMIT 0; \ No newline at end of file diff --git a/swmm_views/21_vw_swmm_weirs.sql b/swmm_views/21_vw_swmm_weirs.sql index 71bf7b97e..c9f41238a 100644 --- a/swmm_views/21_vw_swmm_weirs.sql +++ b/swmm_views/21_vw_swmm_weirs.sql @@ -19,14 +19,18 @@ SELECT WHEN status 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' + ELSE 'secondary' + END as hierarchy, + wn.obj_id as obj_id, NULL as message 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +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) @@ -51,11 +55,15 @@ SELECT WHEN status 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' + ELSE 'secondary' + END as hierarchy, + wn.obj_id as obj_id, concat('Leaping weirs are not supported by SWMM, ', lw.obj_id, 'see: https://swmm5.org/2013/07/19/leaping-weir-example-in-swmm-5-and-infoswmm-alternative/') as message 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file +WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); \ No newline at end of file diff --git a/swmm_views/22_vw_swmm_curves.sql b/swmm_views/22_vw_swmm_curves.sql index 1aad88a46..a192f5d57 100644 --- a/swmm_views/22_vw_swmm_curves.sql +++ b/swmm_views/22_vw_swmm_curves.sql @@ -16,15 +16,19 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_curves AS CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +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) AND pu.obj_id IS NOT NULL @@ -45,15 +49,19 @@ UNION ALL CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +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) AND pw.obj_id IS NOT NULL @@ -74,7 +82,12 @@ UNION ALL CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic 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.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 diff --git a/swmm_views/23_vw_swmm_xsections.sql b/swmm_views/23_vw_swmm_xsections.sql index 18a79d596..874e785e4 100644 --- a/swmm_views/23_vw_swmm_xsections.sql +++ b/swmm_views/23_vw_swmm_xsections.sql @@ -94,7 +94,7 @@ LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile 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_od.channel ch ON ch.obj_id::text = ws.obj_id::text -WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959); +WHERE status IN (6530, 6533, 8493, 6529, 6526, 7959) UNION ALL @@ -112,14 +112,19 @@ SELECT CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' - END as state + END as state, + CASE + WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn.obj_id as obj_id, + NULL as message 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_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 ws._function_hierarchic in (5066, 5068, 5069, 5070, 5064, 5071, 5062, 5072, 5074) -AND status IN (6530, 6533, 8493, 6529, 6526, 7959) +WHERE status 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); diff --git a/swmm_views/24_vw_swmm_coordinates.sql b/swmm_views/24_vw_swmm_coordinates.sql index 2e7970d2f..9170717b3 100644 --- a/swmm_views/24_vw_swmm_coordinates.sql +++ b/swmm_views/24_vw_swmm_coordinates.sql @@ -1,5 +1,11 @@ -------- --- View for the swmm module class coordinates +-- View for the swmm module class coordinate +-- Depends on: +-- - qgep_swmm.vw_junctions +-- - qgep_swmm.vw_outfalls +-- - qgep_swmm.vw_dividers +-- - qgep_swmm.vw_storages +-- - qgep_swmm.vw_raingages -------- CREATE OR REPLACE VIEW qgep_swmm.vw_coordinates AS @@ -25,14 +31,17 @@ SELECT FROM qgep_swmm.vw_outfalls WHERE geom IS NOT NULL --- UNION +UNION --- SELECT - -- Name as Node, - -- ROUND(ST_X(geom)::numeric,2) as X_Coord, - -- ROUND(ST_Y(geom)::numeric,2) as Y_Coord --- FROM qgep_swmm.vw_dividers --- WHERE geom IS NOT NULL +SELECT + Name as Node, + ROUND(ST_X(geom)::numeric,2) as X_Coord, + ROUND(ST_Y(geom)::numeric,2) as Y_Coord, + state, + hierarchy, + obj_id +FROM qgep_swmm.vw_dividers +WHERE geom IS NOT NULL UNION diff --git a/swmm_views/25_vw_swmm_tags.sql b/swmm_views/25_vw_swmm_tags.sql index 58151baf4..eb1d94dcd 100644 --- a/swmm_views/25_vw_swmm_tags.sql +++ b/swmm_views/25_vw_swmm_tags.sql @@ -1,5 +1,12 @@ -------- -- View for the swmm module class tags +-- Depends on: +-- - qgep_swmm.vw_junctions +-- - qgep_swmm.vw_outfalls +-- - qgep_swmm.vw_storages +-- - qgep_swmm.vw_conduits +-- - qgep_swmm.vw_pumps +-- - qgep_swmm.vw_subcatchments -------- CREATE OR REPLACE VIEW qgep_swmm.vw_tags AS diff --git a/swmm_views/26_vw_swmm_symbols.sql b/swmm_views/26_vw_swmm_symbols.sql index 9306dce68..9ae4677c0 100644 --- a/swmm_views/26_vw_swmm_symbols.sql +++ b/swmm_views/26_vw_swmm_symbols.sql @@ -8,5 +8,7 @@ SELECT Name as Gage, st_x(geom) as Xcoord, st_y(geom) as Ycoord, - state as state + state as state, + hierarchy, + obj_id FROM qgep_swmm.vw_raingages From de1bd2f5b79c86676addd6b1d5d73b5dfcd5551c Mon Sep 17 00:00:00 2001 From: Produit Date: Fri, 11 Nov 2022 14:50:42 +0100 Subject: [PATCH 24/39] dividers --- swmm_views/05_vw_swmm_dividers.sql | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index add20407f..dfeecbe05 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -5,14 +5,15 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_dividers AS SELECT ma.obj_id as Name, - wn.bottom_level as Elevation, - NULL as diverted_link, + coalesce(wn.bottom_level,0) as Elevation, + '???' as diverted_link, 'CUTOFF' as Type, 0 as CutoffFlow, 0 as MaxDepth, 0 as InitialDepth, 0 as SurchargeDepth, 0 as PondedArea, + wn.situation_geometry as geom, CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' @@ -35,8 +36,8 @@ UNION ALL SELECT ss.obj_id as Name, - wn.bottom_level as Elevation, - NULL as diverted_link, + coalesce(wn.bottom_level,0) as Elevation, + '???' as diverted_link, 'CUTOFF' as Type, 0 as CutoffFlow, 0 as MaxDepth, From 4893a0752c18060e7e016cd7d4b5c108e30d6008 Mon Sep 17 00:00:00 2001 From: Produit Date: Wed, 16 Nov 2022 16:43:32 +0100 Subject: [PATCH 25/39] separate message and descriptions --- swmm_views/04_vw_swmm_conduits.sql | 92 ++++++++++++++++++++----- swmm_views/08_vw_swmm_outfalls.sql | 2 +- swmm_views/09_vw_swmm_subcatchments.sql | 27 +++++++- swmm_views/10_vw_swmm_subareas.sql | 2 +- swmm_views/11_vw_swmm_dwf.sql | 26 ------- swmm_views/16_vw_swmm_pumps.sql | 24 ++++--- swmm_views/18_vw_swmm_storages.sql | 14 ++-- swmm_views/23_vw_swmm_xsections.sql | 47 +------------ 8 files changed, 125 insertions(+), 109 deletions(-) diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index 4beaa12fa..cf7952cac 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -33,7 +33,76 @@ SELECT coalesce((rp_to.level-to_wn.bottom_level),0) as OutletOffset, 0 as InitFlow, 0 as MaxFlow, - ws.identifier::text as description, + concat_ws(';', + ws.identifier, + CASE + WHEN re.coefficient_of_friction IS NOT NULL THEN '1 / K_Strickler is used as roughness' + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN + CASE + WHEN re.clear_height IS NOT NULL THEN 'The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness as roughness' + WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN 'The default value stored in qgep_swmm.reach_coefficient_of_friction is used' + ELSE 'Default value 0.01 is used as roughness' + END + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN + CASE + WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('The default value stored in qgep_swmm.reach_coefficient_of_friction is used') + ELSE 'Default value 0.01 is used as roughness' + END + ELSE 'Default value 0.01 is used as roughness' + END, + CASE + WHEN pp.profile_type = 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 + 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 + CASE + WHEN pp.height_width_ratio IS NOT NULL THEN + CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with known height_width_ratio value and with default value of 0.1m as clear_height') + ELSE NULL + END + WHEN pp.height_width_ratio IS NULL THEN + CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') + 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 + CASE + WHEN pp.height_width_ratio IS NOT NULL THEN + CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with known height_width_ratio value and with default value of 0.1m as clear_height') + ELSE NULL + END + WHEN pp.height_width_ratio IS NULL THEN + CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') + 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 + CASE + WHEN pp.height_width_ratio IS NOT NULL THEN + CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with known height_width_ratio value, default value of 0.1m as clear_height and no code value') + ELSE NULL + END + WHEN pp.height_width_ratio IS NULL THEN + CASE + WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with default value of 1 as height_width_ratio, with default value of 0.1m as clear_height and no code value') + 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') + END + ) as description, cfh.value_en as tag, ST_CurveToLine(st_force3d(progression_geometry))::geometry(LineStringZ, %(SRID)s) as geom, CASE @@ -45,24 +114,13 @@ SELECT ELSE 'secondary' END as hierarchy, re.obj_id as obj_id, - CASE - WHEN re.coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': 1 / K_Strickler is used as roughness') - WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN - CASE - WHEN re.clear_height IS NOT NULL THEN concat('Reach ', re.obj_id,': The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness as roughness') - WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': The default value stored in qgep_swmm.reach_coefficient_of_friction is used') - ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') - END - WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN - CASE - WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('Reach ', re.obj_id,': The default value stored in qgep_swmm.reach_coefficient_of_friction is used') - ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') - END - -- TODO ROMA: ELSE concat('Reach ', re.obj_id,': Default value 0.01 is used as roughness') - WHEN to_wn.obj_id IS NULL THEN concat(re.obj_id, ' is a blind connection, the destionation node must be edited in SWMM.') - WHEN from_wn.obj_id IS NULL AND to_wn.obj_id IS NOT NULL THEN concat(re.obj_id, ' has no from node, a junction is automatically created for the export.') + CASE + WHEN to_wn.obj_id IS NULL THEN concat(re.obj_id, ' is a blind connection, the destination node must be edited in SWMM.') + WHEN from_wn.obj_id IS NULL AND to_wn.obj_id IS NOT NULL THEN concat(re.obj_id, ' has no from node, a junction is automatically created for the export.') + ELSE NULL END AS message FROM qgep_od.reach as re +LEFT JOIN qgep_od.pipe_profile pp on pp.obj_id = re.fk_pipe_profile 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 diff --git a/swmm_views/08_vw_swmm_outfalls.sql b/swmm_views/08_vw_swmm_outfalls.sql index aa42cda1f..9861eb635 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -10,7 +10,7 @@ SELECT NULL as StageData, 'NO'::varchar as tide_gate, NULL::varchar as RouteTo, - CONCAT(ws.identifier, ', ', ws.remark) as description, + ws.identifier as description, dp.obj_id::varchar as tag, wn.situation_geometry as geom, CASE diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index b4dbaf331..fd84587c4 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -42,7 +42,32 @@ SELECT 0.5 as percSlope, -- default value 0 as CurbLen, -- default value NULL::varchar as SnowPack, -- default value - CONCAT(ca.identifier, ', ', ca.remark) as description, + CASE + WHEN fk_wastewater_networkelement_ww_current is not null + THEN + CASE + WHEN waste_water_production_current IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_current') + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day') + ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day') + END + END + WHEN fk_wastewater_networkelement_ww_planned is not null + THEN + CASE + WHEN waste_water_production_planned IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_planned') + ELSE + CASE + WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day') + ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day') + END + END + WHEN fk_wastewater_networkelement_rw_current is not null + THEN NULL + WHEN fk_wastewater_networkelement_rw_planned is not null + THEN NULL + END as description, ca.obj_id as tag, ST_SimplifyPreserveTopology(ST_CurveToLine(perimeter_geometry), 0.5)::geometry(Polygon, %(SRID)s) as geom, CASE diff --git a/swmm_views/10_vw_swmm_subareas.sql b/swmm_views/10_vw_swmm_subareas.sql index 546ee7e39..f7b0fbd6f 100644 --- a/swmm_views/10_vw_swmm_subareas.sql +++ b/swmm_views/10_vw_swmm_subareas.sql @@ -15,7 +15,7 @@ SELECT 25 as PctZero,-- default value, Percent of the impervious area with no depression storage. 'OUTLET'::varchar as RouteTo, NULL::float as PctRouted, - ca.identifier || ', ' || ca.remark as description, + ca.identifier as description, ca.obj_id::varchar as tag, state as state, CASE diff --git a/swmm_views/11_vw_swmm_dwf.sql b/swmm_views/11_vw_swmm_dwf.sql index 09b284e58..e5f1c031d 100644 --- a/swmm_views/11_vw_swmm_dwf.sql +++ b/swmm_views/11_vw_swmm_dwf.sql @@ -34,32 +34,6 @@ SELECT WHEN fk_wastewater_networkelement_rw_planned is not null THEN 0 END as Baseline, -- 160 Litre / inhabitant /day - CASE - WHEN fk_wastewater_networkelement_ww_current is not null - THEN - CASE - WHEN waste_water_production_current IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_current') - ELSE - CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day') - ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day') - END - END - WHEN fk_wastewater_networkelement_ww_planned is not null - THEN - CASE - WHEN waste_water_production_planned IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_planned') - ELSE - CASE - WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day') - ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day') - END - END - WHEN fk_wastewater_networkelement_rw_current is not null - THEN '' - WHEN fk_wastewater_networkelement_rw_planned is not null - THEN '' - END as message, 'dailyPatternDWF'::varchar as Patterns, state as state, CASE diff --git a/swmm_views/16_vw_swmm_pumps.sql b/swmm_views/16_vw_swmm_pumps.sql index 5cc067be5..b5472c3ab 100644 --- a/swmm_views/16_vw_swmm_pumps.sql +++ b/swmm_views/16_vw_swmm_pumps.sql @@ -15,7 +15,18 @@ SELECT 'ON'::varchar as Status, pu.start_level as StartupDepth, pu.stop_level as ShutoffDepth, - of.identifier as description, + concat_ws(';', + of.identifier, + 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; + THEN 'No curve will be created for this pump, overflow_characteristic_digital not equal to yes' + WHEN oc.kind_overflow_characteristic != 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' @@ -25,16 +36,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - wn.obj_id as obj_id, - CASE - WHEN oc.obj_id IS NULL --'yes; - THEN concat(pu.obj_id, ' No curve will be created for this pump, it has no overflow_characteristic') - WHEN oc.overflow_characteristic_digital != 6223 --'yes; - THEN concat(pu.obj_id, ' No curve will be created for this pump, overflow_characteristic_digital not equal to yes') - WHEN oc.kind_overflow_characteristic != 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 message + 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 diff --git a/swmm_views/18_vw_swmm_storages.sql b/swmm_views/18_vw_swmm_storages.sql index fccc67a9e..5444f6a4a 100644 --- a/swmm_views/18_vw_swmm_storages.sql +++ b/swmm_views/18_vw_swmm_storages.sql @@ -34,8 +34,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - wn.obj_id as obj_id, - NULL as message + 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -114,8 +113,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - wn.obj_id as obj_id, - NULL as message + 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_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text @@ -158,7 +156,10 @@ SELECT NULL as Psi, NULL as Ksat, NULL as IMD, - ws.identifier::text as description, + concat_ws(';', + ws.identifier::text, + concat('Storage created for the prank weir: ', pw.obj_id) + ) as description, 'Prank weir' as tag, wn.situation_geometry as geom, CASE @@ -169,8 +170,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - wn.obj_id as obj_id, - concat(wn.obj_id, ' Storage created for the prank weir: ', pw.obj_id) as message + 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 diff --git a/swmm_views/23_vw_swmm_xsections.sql b/swmm_views/23_vw_swmm_xsections.sql index 874e785e4..8ce815f9b 100644 --- a/swmm_views/23_vw_swmm_xsections.sql +++ b/swmm_views/23_vw_swmm_xsections.sql @@ -46,49 +46,7 @@ SELECT DISTINCT WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - re.obj_id as obj_id, - --message give details about the profile type, height availability, width availability if needed and code availablitity if needed. To much details? - CASE - WHEN pp.profile_type = 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 concat('Reach', re.obj_id,': circular profile with known clear_height value') - END - WHEN pp.profile_type = 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 concat('Reach', re.obj_id,': egg profile with known clear_height value') - END - WHEN pp.profile_type = 3352 THEN CASE - WHEN pp.height_width_ratio IS NOT NULL THEN CASE - WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with known height_width_ratio value and with default value of 0.1m as clear_height') - ELSE concat('Reach', re.obj_id,': arch profile with known height_width_ratio value and with known clear_height value') - END - WHEN pp.height_width_ratio IS NULL THEN CASE - WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') - 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 CASE - WHEN pp.height_width_ratio IS NOT NULL THEN CASE - WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with known height_width_ratio value and with default value of 0.1m as clear_height') - ELSE concat('Reach', re.obj_id,': rectangular profile with known height_width_ratio value and with known clear_height value') - END - WHEN pp.height_width_ratio IS NULL THEN CASE - WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') - 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 CASE - WHEN pp.height_width_ratio IS NOT NULL THEN CASE - WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with known height_width_ratio value, default value of 0.1m as clear_height and no code value') - ELSE concat('Reach', re.obj_id,': parabolic profile with known height_width_ratio value, with known clear_height value and no code value') - END - WHEN pp.height_width_ratio IS NULL THEN CASE - WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with default value of 1 as height_width_ratio, with default value of 0.1m as clear_height and no code value') - 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') - END as message + 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_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text @@ -117,8 +75,7 @@ SELECT WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - wn.obj_id as obj_id, - NULL as message + 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 From cbe21da11a99e9c97b863475d3789ee2ca6a27a6 Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 24 Nov 2022 15:43:19 +0100 Subject: [PATCH 26/39] merge and doc --- swmm_views/04_vw_swmm_conduits.sql | 16 ++++++++-------- swmm_views/09_vw_swmm_subcatchments.sql | 2 +- swmm_views/11_vw_swmm_dwf.sql | 4 ++-- swmm_views/14_vw_swmm_coverages.sql | 3 ++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index cf7952cac..ed005e996 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -40,12 +40,12 @@ SELECT WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN CASE WHEN re.clear_height IS NOT NULL THEN 'The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness as roughness' - WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN 'The default value stored in qgep_swmm.reach_coefficient_of_friction is used' + WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN 'The default value stored in reach.default_coefficient_of_friction is used' ELSE 'Default value 0.01 is used as roughness' END WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN CASE - WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('The default value stored in qgep_swmm.reach_coefficient_of_friction is used') + WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('The default value stored in reach.default_coefficient_of_friction is used') ELSE 'Default value 0.01 is used as roughness' END ELSE 'Default value 0.01 is used as roughness' @@ -101,6 +101,11 @@ SELECT END END WHEN pp.profile_type = 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' + WHEN from_wn.obj_id IS NULL AND to_wn.obj_id IS NOT NULL THEN 'No from node, a junction was automatically created for the export.' + ELSE NULL END ) as description, cfh.value_en as tag, @@ -113,12 +118,7 @@ SELECT WHEN ch.function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, - re.obj_id as obj_id, - CASE - WHEN to_wn.obj_id IS NULL THEN concat(re.obj_id, ' is a blind connection, the destination node must be edited in SWMM.') - WHEN from_wn.obj_id IS NULL AND to_wn.obj_id IS NOT NULL THEN concat(re.obj_id, ' has no from node, a junction is automatically created for the export.') - ELSE NULL - END AS message + 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_od.wastewater_networkelement ne ON ne.obj_id::text = re.obj_id::text diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index fd84587c4..47452fd30 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -69,7 +69,7 @@ SELECT THEN NULL END as description, ca.obj_id as tag, - ST_SimplifyPreserveTopology(ST_CurveToLine(perimeter_geometry), 0.5)::geometry(Polygon, %(SRID)s) as geom, + ST_CurveToLine(perimeter_geometry)::geometry(Polygon, %(SRID)s) as geom, CASE WHEN state = 'rw_current' OR state = 'ww_current' THEN 'current' WHEN state = 'rw_planned' OR state = 'ww_planned' THEN 'planned' diff --git a/swmm_views/11_vw_swmm_dwf.sql b/swmm_views/11_vw_swmm_dwf.sql index e5f1c031d..ec55b8741 100644 --- a/swmm_views/11_vw_swmm_dwf.sql +++ b/swmm_views/11_vw_swmm_dwf.sql @@ -16,7 +16,7 @@ SELECT ELSE CASE WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) - ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) / 10000 * 160 / (24 * 60 * 60) END END WHEN fk_wastewater_networkelement_ww_planned is not null @@ -26,7 +26,7 @@ SELECT ELSE CASE WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_planned,0) * surface_area * 160 / (24 * 60 * 60) - ELSE coalesce(population_density_planned,0) * ST_Area(perimeter_geometry) * 160 / (24 * 60 * 60) + ELSE coalesce(population_density_planned,0) * ST_Area(perimeter_geometry) / 10000 * 160 / (24 * 60 * 60) END END WHEN fk_wastewater_networkelement_rw_current is not null diff --git a/swmm_views/14_vw_swmm_coverages.sql b/swmm_views/14_vw_swmm_coverages.sql index 4a7603ffd..340fe6369 100644 --- a/swmm_views/14_vw_swmm_coverages.sql +++ b/swmm_views/14_vw_swmm_coverages.sql @@ -6,7 +6,8 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_coverages AS SELECT sub.Name as Subcatchment, pzk.value_en as landUse, - round((st_area(st_intersection(sub.geom, pz.perimeter_geometry))/st_area(sub.geom))::numeric,2)*100 as percent + round((st_area(st_intersection(sub.geom, pz.perimeter_geometry))/st_area(sub.geom))::numeric,2)*100 as percent, + sub.obj_id FROM qgep_swmm.vw_subcatchments sub, qgep_od.planning_zone pz LEFT JOIN qgep_vl.planning_zone_kind pzk on pz.kind = pzk.code WHERE st_intersects(sub.geom, pz.perimeter_geometry) From 0aab5f27672069c64f7be8deba278fa5896feb6a Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 29 Nov 2022 15:02:27 +0100 Subject: [PATCH 27/39] add comments --- 03_qgep_db_dss.sql | 4 ++-- 09_qgep_dictionaries.sql | 2 ++ ...elta_1.5.X_add_reach_default_coefficient_friction.sql | 4 ++-- swmm_views/04_vw_swmm_conduits.sql | 9 +++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index 404f4e587..2852a5181 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -1887,8 +1887,8 @@ ALTER TABLE qgep_od.reach ADD COLUMN clear_height integer ; COMMENT ON COLUMN qgep_od.reach.clear_height IS 'Maximal height (inside) of profile / Maximale Innenhöhe des Kanalprofiles / Hauteur intérieure maximale du profil'; ALTER TABLE qgep_od.reach ADD COLUMN coefficient_of_friction smallint ; COMMENT ON COLUMN qgep_od.reach.coefficient_of_friction IS 'yyy http://www.linguee.com/english-german/search?source=auto&query=reibungsbeiwert / Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Manning-Strickler (K oder kstr) / Constante de rugosité selon Manning-Strickler (K ou kstr)'; -ALTER TABLE qgep_od.reach ADD COLUMN default_coefficient_of_friction smallint ; -COMMENT ON COLUMN qgep_od.reach.default_coefficient_of_friction IS 'yyy http://www.fsl.orst.edu/geowater/FX3/help/8_Hydraulic_Reference/Mannings_n_Tables.htm / (1 / N_Manning) value between 0 and 999'; +ALTER TABLE qgep_od.reach ADD COLUMN swmm_default_coefficient_of_friction smallint ; +COMMENT ON COLUMN qgep_od.reach.swmm_default_coefficient_of_friction IS '1 / N_Manning, value between 0 and 999. Value exported in SWMM if coefficient_of_friction and wall_roughness are not set. '; ALTER TABLE qgep_od.reach ADD COLUMN elevation_determination integer ; COMMENT ON COLUMN qgep_od.reach.elevation_determination IS 'yyy_Definiert die Hoehenbestimmung einer Haltung. / Definiert die Hoehenbestimmung einer Haltung. / Définition de la détermination altimétrique d''un tronçon.'; ALTER TABLE qgep_od.reach ADD COLUMN horizontal_positioning integer ; diff --git a/09_qgep_dictionaries.sql b/09_qgep_dictionaries.sql index 492d5c852..08795bd7b 100644 --- a/09_qgep_dictionaries.sql +++ b/09_qgep_dictionaries.sql @@ -485,6 +485,8 @@ CREATE TABLE qgep_sys.dictionary_od_field ( INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,4789,'reach','ring_stiffness','ring_stiffness','Ringsteifigkeit','RIGIDITE_ANNULAIRE','zzz_Ringsteifigkeit','rigiditate_inelara','yyy Ringsteifigkeitsklasse - Druckfestigkeit gegen Belastungen von aussen (gemäss ISO 13966 )','Ringsteifigkeitsklasse - Druckfestigkeit gegen Belastungen von aussen (gemäss ISO 13966 )','[kN/m2]','[kN/m2]','[kN/m2]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','smallint','[kN/m2]','[kN/m2]','[kN/m2]','[kN/m2]','','','','','','',0,16); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,4800,'reach','slope_building_plan','slope_building_plan','Plangefaelle','PENTE_PLAN','zzz_Plangefaelle','panta_planificata','yyy_Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.','Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.',' [%o]',' [%o]',' [%o]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','smallint',' [%o]','promille [%o]',' [%o]','Promille [%o]','','','','','','',-10000,10000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,129,'reach','wall_roughness','wall_roughness','Wandrauhigkeit','K_COLEBROOK','zzz_Wandrauhigkeit','rugozitate_perete','yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','[mm]','[mm]','[mm]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','decimal(5,2)','[mm]','roughness coefficient after Prandtl Colebrook (ks), unit milimeter [mm]','[mm]','Wandrauhigkeitsbeiwert nach Prandtl Colebrook (ks), Milimeter [mm]','','','','','','',0,100); + INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','swmm_default_coefficient_of_friction','swmm_default_coefficient_of_friction',NULL,NULL,NULL,NULL,Default coefficient of friction for SWMM export.',NULL,NULL,NULL,NULL,NULL,'true','smallint',[m^(1/3)/s]','Manning-StricklerÊKÊorÊkstrÊ[m^(1/3)/s]','[m^(1/3)/s]','Manning-StricklerÊKÊoderÊkstrÊ[m^(1/3)/s]','','','','','','',0,999); + INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','hydraulic_load','hydraulic_load',NULL,NULL,NULL,NULL,Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].',Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].',DŽbit de dimensionnement divisŽ par la capacitŽ d''Žcoulement normale de la conduite [%].',NULL,NULL,NULL,'true',decimal(7,3)',[%]',Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].','','','','','','',0,100); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3558,'param_ca_general','dry_wheather_flow','dry_wheather_flow','Trockenwetteranfall','DEBIT_TEMPS_SEC','zzz_Trockenwetteranfall','fluxul_de_vreme_uscata','Dry wheather flow','NULL','[l/s]','[l/s]','[l/s]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(9,3)','[l/s]','liters per second [l/s]','[l/s]','Liter pro Sekunde [l/s]','','','','','','',0,100000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3195,'param_ca_general','flow_path_length','flow_path_length','Fliessweglaenge','L_LIGNE_ECOULEMENT','zzz_Fliessweglaenge','lungimea_traseului_de_curgere','Length of flow path','Fliessweglänge','[m]','[m]','[m]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(7,2)','[m]','meter [m], 2 decimal digits','[m]','Meter [m], 2 Dezimalstellen','','','','','','',0,30000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3194,'param_ca_general','flow_path_slope','flow_path_slope','Fliessweggefaelle','P_LIGNE_ECOULEMENT','zzz_Fliessweggefaelle','panta_traseului_de_curgere','Slope of flow path [%o]','Fliessweggefälle [%o]','[%o]','[%o]','[%o]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','smallint','[%o]','permill [%]','[%o]','Promille [%o]','','','','','','',0,1000); diff --git a/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql b/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql index 4b142562a..9c16bc1b9 100644 --- a/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql +++ b/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql @@ -1,2 +1,2 @@ -ALTER TABLE qgep_od.reach ADD COLUMN default_coefficient_of_friction smallint ; -COMMENT ON COLUMN qgep_od.reach.default_coefficient_of_friction IS 'yyy http://www.fsl.orst.edu/geowater/FX3/help/8_Hydraulic_Reference/Mannings_n_Tables.htm / (1 / N_Manning) value between 0 and 999'; +ALTER TABLE qgep_od.reach ADD COLUMN swmm_default_coefficient_of_friction smallint ; +COMMENT ON COLUMN qgep_od.reach.swmm_default_coefficient_of_friction IS 'yyy http://www.fsl.orst.edu/geowater/FX3/help/8_Hydraulic_Reference/Mannings_n_Tables.htm / (1 / N_Manning) value between 0 and 999'; diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index ed005e996..e031e16cb 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -14,17 +14,18 @@ SELECT WHEN re.length_effective IS NULL AND st_length(progression_geometry) >= 0.01 THEN st_length(progression_geometry) ELSE re.length_effective END as Length, + -- Roughness export prioriy: 1. coefficient_of_friction, 2. wall_roughness, 3. swmm_default_coefficient_of_friction, 4. 0.01 CASE WHEN re.coefficient_of_friction IS NOT NULL THEN (1 / re.coefficient_of_friction::double precision) WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN CASE WHEN re.clear_height IS NOT NULL THEN (1 / (4 * SQRT(9.81) * POWER((32 / re.clear_height::double precision / 1000),(1 / 6::double precision))*LOG(((3.71 * re.clear_height::double precision / 1000) / (re.wall_roughness / 1000)))))::numeric(7,4) - WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN (1 / re.default_coefficient_of_friction::double precision) + WHEN re.clear_height IS NULL AND re.swmm_default_coefficient_of_friction IS NOT NULL THEN (1 / re.swmm_default_coefficient_of_friction::double precision) ELSE 0.01 END WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN CASE - WHEN re.default_coefficient_of_friction IS NOT NULL THEN (1 / re.default_coefficient_of_friction::double precision) + WHEN re.swmm_default_coefficient_of_friction IS NOT NULL THEN (1 / re.swmm_default_coefficient_of_friction::double precision) ELSE 0.01 END ELSE 0.01 @@ -40,12 +41,12 @@ SELECT WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN CASE WHEN re.clear_height IS NOT NULL THEN 'The approximation of 1 / K_Strickler is computed using K_Colebrook to determined the roughness as roughness' - WHEN re.clear_height IS NULL AND re.default_coefficient_of_friction IS NOT NULL THEN 'The default value stored in reach.default_coefficient_of_friction is used' + WHEN re.clear_height IS NULL AND re.swmm_default_coefficient_of_friction IS NOT NULL THEN 'The default value stored in reach.swmm_default_coefficient_of_friction is used' ELSE 'Default value 0.01 is used as roughness' END WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NULL THEN CASE - WHEN re.default_coefficient_of_friction IS NOT NULL THEN concat('The default value stored in reach.default_coefficient_of_friction is used') + WHEN re.swmm_default_coefficient_of_friction IS NOT NULL THEN concat('The default value stored in reach.swmm_default_coefficient_of_friction is used') ELSE 'Default value 0.01 is used as roughness' END ELSE 'Default value 0.01 is used as roughness' From 70915af535723a442c284a313a8ffbc15f3aa5be Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 11:29:07 +0100 Subject: [PATCH 28/39] add new lines --- swmm_views/09_vw_swmm_subcatchments.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index 47452fd30..be8c62524 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -81,22 +81,26 @@ 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 + 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 + 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 + 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 + 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 From 671fdfb676f3b4bf307dbece1e769ee40548c6a1 Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 11:46:19 +0100 Subject: [PATCH 29/39] renumber file --- swmm_views/{17_vw_swmm_results.sql => 27_vw_swmm_results.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename swmm_views/{17_vw_swmm_results.sql => 27_vw_swmm_results.sql} (100%) diff --git a/swmm_views/17_vw_swmm_results.sql b/swmm_views/27_vw_swmm_results.sql similarity index 100% rename from swmm_views/17_vw_swmm_results.sql rename to swmm_views/27_vw_swmm_results.sql From 34f47ff4d04c988971c23c1ba3910674f808e130 Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 11:50:22 +0100 Subject: [PATCH 30/39] add version number --- ...l => delta_1.5.8_add_reach_default_coefficient_friction.sql} | 0 ...raulic_load.sql => delta_1.5.8_add_reach_hydraulic_load.sql} | 0 ...iction.sql => delta_1.5.8_tbl_swmm_coefficient_friction.sql} | 0 system/CURRENT_VERSION.txt | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename delta/{delta_1.5.X_add_reach_default_coefficient_friction.sql => delta_1.5.8_add_reach_default_coefficient_friction.sql} (100%) rename delta/{delta_1.5.X_add_reach_hydraulic_load.sql => delta_1.5.8_add_reach_hydraulic_load.sql} (100%) rename delta/{delta_1.5.X_tbl_swmm_coefficient_friction.sql => delta_1.5.8_tbl_swmm_coefficient_friction.sql} (100%) diff --git a/delta/delta_1.5.X_add_reach_default_coefficient_friction.sql b/delta/delta_1.5.8_add_reach_default_coefficient_friction.sql similarity index 100% rename from delta/delta_1.5.X_add_reach_default_coefficient_friction.sql rename to delta/delta_1.5.8_add_reach_default_coefficient_friction.sql diff --git a/delta/delta_1.5.X_add_reach_hydraulic_load.sql b/delta/delta_1.5.8_add_reach_hydraulic_load.sql similarity index 100% rename from delta/delta_1.5.X_add_reach_hydraulic_load.sql rename to delta/delta_1.5.8_add_reach_hydraulic_load.sql diff --git a/delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql b/delta/delta_1.5.8_tbl_swmm_coefficient_friction.sql similarity index 100% rename from delta/delta_1.5.X_tbl_swmm_coefficient_friction.sql rename to delta/delta_1.5.8_tbl_swmm_coefficient_friction.sql diff --git a/system/CURRENT_VERSION.txt b/system/CURRENT_VERSION.txt index f01291b87..1cc9c180e 100644 --- a/system/CURRENT_VERSION.txt +++ b/system/CURRENT_VERSION.txt @@ -1 +1 @@ -1.5.7 +1.5.8 From b94d40e888518cb6e13f33140fbbab2b93496e8c Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 12:01:50 +0100 Subject: [PATCH 31/39] change field description --- 09_qgep_dictionaries.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/09_qgep_dictionaries.sql b/09_qgep_dictionaries.sql index 08795bd7b..593f64b41 100644 --- a/09_qgep_dictionaries.sql +++ b/09_qgep_dictionaries.sql @@ -485,8 +485,8 @@ CREATE TABLE qgep_sys.dictionary_od_field ( INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,4789,'reach','ring_stiffness','ring_stiffness','Ringsteifigkeit','RIGIDITE_ANNULAIRE','zzz_Ringsteifigkeit','rigiditate_inelara','yyy Ringsteifigkeitsklasse - Druckfestigkeit gegen Belastungen von aussen (gemäss ISO 13966 )','Ringsteifigkeitsklasse - Druckfestigkeit gegen Belastungen von aussen (gemäss ISO 13966 )','[kN/m2]','[kN/m2]','[kN/m2]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','smallint','[kN/m2]','[kN/m2]','[kN/m2]','[kN/m2]','','','','','','',0,16); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,4800,'reach','slope_building_plan','slope_building_plan','Plangefaelle','PENTE_PLAN','zzz_Plangefaelle','panta_planificata','yyy_Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.','Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.',' [%o]',' [%o]',' [%o]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','smallint',' [%o]','promille [%o]',' [%o]','Promille [%o]','','','','','','',-10000,10000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,129,'reach','wall_roughness','wall_roughness','Wandrauhigkeit','K_COLEBROOK','zzz_Wandrauhigkeit','rugozitate_perete','yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','[mm]','[mm]','[mm]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','decimal(5,2)','[mm]','roughness coefficient after Prandtl Colebrook (ks), unit milimeter [mm]','[mm]','Wandrauhigkeitsbeiwert nach Prandtl Colebrook (ks), Milimeter [mm]','','','','','','',0,100); - INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','swmm_default_coefficient_of_friction','swmm_default_coefficient_of_friction',NULL,NULL,NULL,NULL,Default coefficient of friction for SWMM export.',NULL,NULL,NULL,NULL,NULL,'true','smallint',[m^(1/3)/s]','Manning-StricklerÊKÊorÊkstrÊ[m^(1/3)/s]','[m^(1/3)/s]','Manning-StricklerÊKÊoderÊkstrÊ[m^(1/3)/s]','','','','','','',0,999); - INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','hydraulic_load','hydraulic_load',NULL,NULL,NULL,NULL,Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].',Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].',DŽbit de dimensionnement divisŽ par la capacitŽ d''Žcoulement normale de la conduite [%].',NULL,NULL,NULL,'true',decimal(7,3)',[%]',Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch NormalabflusskapazitŠt der Leitung [%].','','','','','','',0,100); + INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','swmm_default_coefficient_of_friction','swmm_default_coefficient_of_friction',NULL,NULL,NULL,NULL,'Default coefficient of friction for SWMM export.',NULL,NULL,NULL,NULL,NULL,'true','smallint','[m^(1/3)/s]','Manning-Strickler [m^(1/3)/s]','[m^(1/3)/s]','Manning-Strickler [m^(1/3)/s]','','','','','','',0,999); + INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','hydraulic_load','hydraulic_load',NULL,NULL,NULL,NULL,'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].',NULL,NULL,NULL,'true',decimal(7,3)',[%]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','','','','','','',0,100); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3558,'param_ca_general','dry_wheather_flow','dry_wheather_flow','Trockenwetteranfall','DEBIT_TEMPS_SEC','zzz_Trockenwetteranfall','fluxul_de_vreme_uscata','Dry wheather flow','NULL','[l/s]','[l/s]','[l/s]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(9,3)','[l/s]','liters per second [l/s]','[l/s]','Liter pro Sekunde [l/s]','','','','','','',0,100000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3195,'param_ca_general','flow_path_length','flow_path_length','Fliessweglaenge','L_LIGNE_ECOULEMENT','zzz_Fliessweglaenge','lungimea_traseului_de_curgere','Length of flow path','Fliessweglänge','[m]','[m]','[m]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(7,2)','[m]','meter [m], 2 decimal digits','[m]','Meter [m], 2 Dezimalstellen','','','','','','',0,30000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3194,'param_ca_general','flow_path_slope','flow_path_slope','Fliessweggefaelle','P_LIGNE_ECOULEMENT','zzz_Fliessweggefaelle','panta_traseului_de_curgere','Slope of flow path [%o]','Fliessweggefälle [%o]','[%o]','[%o]','[%o]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','smallint','[%o]','permill [%]','[%o]','Promille [%o]','','','','','','',0,1000); From 70d3ad2f336a9b613a86f210dff3124ee7c00b21 Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 12:07:53 +0100 Subject: [PATCH 32/39] change field description --- 09_qgep_dictionaries.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09_qgep_dictionaries.sql b/09_qgep_dictionaries.sql index 593f64b41..9a9f3cf6c 100644 --- a/09_qgep_dictionaries.sql +++ b/09_qgep_dictionaries.sql @@ -486,7 +486,7 @@ CREATE TABLE qgep_sys.dictionary_od_field ( INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,4800,'reach','slope_building_plan','slope_building_plan','Plangefaelle','PENTE_PLAN','zzz_Plangefaelle','panta_planificata','yyy_Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.','Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.',' [%o]',' [%o]',' [%o]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','smallint',' [%o]','promille [%o]',' [%o]','Promille [%o]','','','','','','',-10000,10000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,129,'reach','wall_roughness','wall_roughness','Wandrauhigkeit','K_COLEBROOK','zzz_Wandrauhigkeit','rugozitate_perete','yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','[mm]','[mm]','[mm]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','decimal(5,2)','[mm]','roughness coefficient after Prandtl Colebrook (ks), unit milimeter [mm]','[mm]','Wandrauhigkeitsbeiwert nach Prandtl Colebrook (ks), Milimeter [mm]','','','','','','',0,100); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','swmm_default_coefficient_of_friction','swmm_default_coefficient_of_friction',NULL,NULL,NULL,NULL,'Default coefficient of friction for SWMM export.',NULL,NULL,NULL,NULL,NULL,'true','smallint','[m^(1/3)/s]','Manning-Strickler [m^(1/3)/s]','[m^(1/3)/s]','Manning-Strickler [m^(1/3)/s]','','','','','','',0,999); - INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','hydraulic_load','hydraulic_load',NULL,NULL,NULL,NULL,'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].',NULL,NULL,NULL,'true',decimal(7,3)',[%]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','','','','','','',0,100); + INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','hydraulic_load','hydraulic_load',NULL,NULL,NULL,NULL,'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].',NULL,NULL,NULL,'true','decimal(7,3)','[%]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','','','','','','',0,100); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3558,'param_ca_general','dry_wheather_flow','dry_wheather_flow','Trockenwetteranfall','DEBIT_TEMPS_SEC','zzz_Trockenwetteranfall','fluxul_de_vreme_uscata','Dry wheather flow','NULL','[l/s]','[l/s]','[l/s]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(9,3)','[l/s]','liters per second [l/s]','[l/s]','Liter pro Sekunde [l/s]','','','','','','',0,100000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3195,'param_ca_general','flow_path_length','flow_path_length','Fliessweglaenge','L_LIGNE_ECOULEMENT','zzz_Fliessweglaenge','lungimea_traseului_de_curgere','Length of flow path','Fliessweglänge','[m]','[m]','[m]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(7,2)','[m]','meter [m], 2 decimal digits','[m]','Meter [m], 2 Dezimalstellen','','','','','','',0,30000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3194,'param_ca_general','flow_path_slope','flow_path_slope','Fliessweggefaelle','P_LIGNE_ECOULEMENT','zzz_Fliessweggefaelle','panta_traseului_de_curgere','Slope of flow path [%o]','Fliessweggefälle [%o]','[%o]','[%o]','[%o]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','smallint','[%o]','permill [%]','[%o]','Promille [%o]','','','','','','',0,1000); From 03110489c425f81a6341ba5f8433e3f8bc18d2ac Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 13:54:50 +0100 Subject: [PATCH 33/39] update view in create_views.py --- view/create_views.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/view/create_views.py b/view/create_views.py index ef7be0567..3ef16df9d 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -83,13 +83,24 @@ def create_views(srid: int, run_sql('swmm_views/07_vw_swmm_losses.sql', pg_service, variables) run_sql('swmm_views/08_vw_swmm_outfalls.sql', pg_service, variables) run_sql('swmm_views/09_vw_swmm_subcatchments.sql', pg_service, variables) - run_sql('swmm_views/10_vw_swmm_vertices.sql', pg_service, variables) - run_sql('swmm_views/11_vw_swmm_pumps.sql', pg_service, variables) - run_sql('swmm_views/12_vw_swmm_polygons.sql', pg_service, variables) - run_sql('swmm_views/13_vw_swmm_storages.sql', pg_service, variables) - run_sql('swmm_views/14_vw_swmm_xsections.sql', pg_service, variables) - run_sql('swmm_views/15_vw_swmm_coordinates.sql', pg_service, variables) - run_sql('swmm_views/16_vw_swmm_tags.sql', pg_service, variables) + run_sql('swmm_views/10_vw_swmm_subareas.sql', pg_service, variables) + run_sql('swmm_views/11_vw_swmm_dwf.sql', pg_service, variables) + run_sql('swmm_views/12_vw_swmm_raingages.sql', pg_service, variables) + run_sql('swmm_views/13_vw_swmm_infiltrations.sql', pg_service, variables) + run_sql('swmm_views/14_vw_swmm_coverages.sql', pg_service, variables) + run_sql('swmm_views/15_vw_swmm_vertices.sql', pg_service, variables) + run_sql('swmm_views/16_vw_swmm_pumps.sql', pg_service, variables) + run_sql('swmm_views/17_vw_swmm_polygons.sql', pg_service, variables) + run_sql('swmm_views/18_vw_swmm_storages.sql', pg_service, variables) + run_sql('swmm_views/19_vw_swmm_outlets.sql', pg_service, variables) + run_sql('swmm_views/20_vw_swmm_orifices.sql', pg_service, variables) + run_sql('swmm_views/21_vw_swmm_weirs.sql', pg_service, variables) + run_sql('swmm_views/22_vw_swmm_curves.sql', pg_service, variables) + run_sql('swmm_views/23_vw_swmm_xsections.sql', pg_service, variables) + run_sql('swmm_views/24_vw_swmm_coordinates.sql', pg_service, variables) + run_sql('swmm_views/25_vw_swmm_tags.sql', pg_service, variables) + run_sql('swmm_views/26_vw_swmm_symbols.sql', pg_service, variables) + run_sql('swmm_views/27_vw_swmm_results.sql', pg_service, variables) SimpleJoins(safe_load(open('view/export/vw_export_reach.yaml')), pg_service).create() SimpleJoins(safe_load(open('view/export/vw_export_wastewater_structure.yaml')), pg_service).create() From 9256a551513541dc701cf8c6f1bb18cd3ff09a47 Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 15:53:19 +0100 Subject: [PATCH 34/39] escape % in delta --- delta/delta_1.5.8_add_reach_hydraulic_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delta/delta_1.5.8_add_reach_hydraulic_load.sql b/delta/delta_1.5.8_add_reach_hydraulic_load.sql index 8307b0ac6..2f07a665b 100644 --- a/delta/delta_1.5.8_add_reach_hydraulic_load.sql +++ b/delta/delta_1.5.8_add_reach_hydraulic_load.sql @@ -1,2 +1,2 @@ ALTER TABLE qgep_od.reach ADD COLUMN hydraulic_load decimal(7,3) ; -COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; \ No newline at end of file +COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%%].'; \ No newline at end of file From 9444a15704f3f87dd5b60f86a225d1101a524c6c Mon Sep 17 00:00:00 2001 From: Produit Date: Tue, 6 Dec 2022 16:02:50 +0100 Subject: [PATCH 35/39] comment swmm test --- test/test_swmm.py | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/test/test_swmm.py b/test/test_swmm.py index 800b49895..db02f6481 100644 --- a/test/test_swmm.py +++ b/test/test_swmm.py @@ -23,65 +23,65 @@ def setUp(cls): pgservice=os.environ.get('PGSERVICE') or 'pg_qgep' cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) - def test_count_vw_aquifers(self): - self.assert_count("vw_aquifers", "qgep_swmm", 0) + # def test_count_vw_aquifers(self): + # self.assert_count("vw_aquifers", "qgep_swmm", 0) - def test_count_vw_conduits(self): - self.assert_count("vw_conduits", "qgep_swmm", 5095) + # def test_count_vw_conduits(self): + # self.assert_count("vw_conduits", "qgep_swmm", 5095) - def test_count_vw_coordinates(self): - self.assert_count("vw_coordinates", "qgep_swmm", 6686) + # def test_count_vw_coordinates(self): + # self.assert_count("vw_coordinates", "qgep_swmm", 6686) - def test_count_vw_coverages(self): - self.assert_count("vw_coverages", "qgep_swmm", 0) + # def test_count_vw_coverages(self): + # self.assert_count("vw_coverages", "qgep_swmm", 0) - def test_count_vw_dividers(self): - self.assert_count("vw_dividers", "qgep_swmm", 41) + # def test_count_vw_dividers(self): + # self.assert_count("vw_dividers", "qgep_swmm", 41) - def test_count_vw_dwf(self): - self.assert_count("vw_dwf", "qgep_swmm", 1352) + # def test_count_vw_dwf(self): + # self.assert_count("vw_dwf", "qgep_swmm", 1352) - def test_count_vw_infiltration(self): - self.assert_count("vw_infiltration", "qgep_swmm", 1352) + # def test_count_vw_infiltration(self): + # self.assert_count("vw_infiltration", "qgep_swmm", 1352) - def test_count_vw_junctions(self): - self.assert_count("vw_junctions", "qgep_swmm", 4575) + # def test_count_vw_junctions(self): + # self.assert_count("vw_junctions", "qgep_swmm", 4575) - def test_count_vw_landuses(self): - self.assert_count("vw_landuses", "qgep_swmm", 6) + # def test_count_vw_landuses(self): + # self.assert_count("vw_landuses", "qgep_swmm", 6) - def test_count_vw_losses(self): - self.assert_count("vw_losses", "qgep_swmm", 1053) + # def test_count_vw_losses(self): + # self.assert_count("vw_losses", "qgep_swmm", 1053) - def test_count_vw_outfalls(self): - self.assert_count("vw_outfalls", "qgep_swmm", 54) + # def test_count_vw_outfalls(self): + # self.assert_count("vw_outfalls", "qgep_swmm", 54) - def test_count_vw_polygons(self): - self.assert_count("vw_polygons", "qgep_swmm", 27405) + # def test_count_vw_polygons(self): + # self.assert_count("vw_polygons", "qgep_swmm", 27405) - def test_count_vw_pumps(self): - self.assert_count("vw_pumps", "qgep_swmm", 0) + # def test_count_vw_pumps(self): + # self.assert_count("vw_pumps", "qgep_swmm", 0) - def test_count_vw_raingages(self): - self.assert_count("vw_raingages", "qgep_swmm", 2035) + # def test_count_vw_raingages(self): + # self.assert_count("vw_raingages", "qgep_swmm", 2035) - def test_count_vw_storages(self): - self.assert_count("vw_storages", "qgep_swmm", 23) + # def test_count_vw_storages(self): + # self.assert_count("vw_storages", "qgep_swmm", 23) - def test_count_vw_subareas(self): - self.assert_count("vw_subareas", "qgep_swmm", 2035) + # def test_count_vw_subareas(self): + # self.assert_count("vw_subareas", "qgep_swmm", 2035) - def test_count_vw_subcatchments(self): - self.assert_count("vw_subcatchments", "qgep_swmm", 2035) + # def test_count_vw_subcatchments(self): + # self.assert_count("vw_subcatchments", "qgep_swmm", 2035) - def test_count_vw_tags(self): - self.assert_count("vw_tags", "qgep_swmm", 11782) + # def test_count_vw_tags(self): + # self.assert_count("vw_tags", "qgep_swmm", 11782) - def test_count_vw_vertices(self): - self.assert_count("vw_vertices", "qgep_swmm", 2854) + # def test_count_vw_vertices(self): + # self.assert_count("vw_vertices", "qgep_swmm", 2854) - def test_count_vw_xsections(self): - self.assert_count("vw_xsections", "qgep_swmm", 5095) + # def test_count_vw_xsections(self): + # self.assert_count("vw_xsections", "qgep_swmm", 5095) if __name__ == '__main__': unittest.main() From 8f69a42b6a7ecfae239165c86669c84deb87336b Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 15 Dec 2022 08:41:16 +0100 Subject: [PATCH 36/39] Sjb remarks --- 05_data_model_extensions.sql | 7 ++ 09_qgep_dictionaries.sql | 2 +- .../delta_1.5.8_add_reach_hydraulic_load.sql | 4 +- test/test_swmm.py | 80 +++++++++---------- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/05_data_model_extensions.sql b/05_data_model_extensions.sql index 8540b9f62..43df4be67 100644 --- a/05_data_model_extensions.sql +++ b/05_data_model_extensions.sql @@ -78,3 +78,10 @@ ALTER TABLE qgep_od.wastewater_node ADD COLUMN _function_hierarchic integer; COMMENT ON COLUMN qgep_od.wastewater_node._function_hierarchic IS 'not part of the VSA-DSS data model added solely for QGEP has to be updated by triggers'; + + +-- Modifications done for link with SWMM +ALTER TABLE qgep_od.reach ADD COLUMN swmm_default_coefficient_of_friction smallint ; +COMMENT ON COLUMN qgep_od.reach.swmm_default_coefficient_of_friction IS '1 / N_Manning, value between 0 and 999. Value exported in SWMM if coefficient_of_friction and wall_roughness are not set. '; +ALTER TABLE qgep_od.reach ADD COLUMN dss2020_hydraulic_load_current smallint ; +COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%]. / Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; diff --git a/09_qgep_dictionaries.sql b/09_qgep_dictionaries.sql index 9a9f3cf6c..f3f1ff4a0 100644 --- a/09_qgep_dictionaries.sql +++ b/09_qgep_dictionaries.sql @@ -486,7 +486,7 @@ CREATE TABLE qgep_sys.dictionary_od_field ( INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,4800,'reach','slope_building_plan','slope_building_plan','Plangefaelle','PENTE_PLAN','zzz_Plangefaelle','panta_planificata','yyy_Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.','Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen.',' [%o]',' [%o]',' [%o]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','smallint',' [%o]','promille [%o]',' [%o]','Promille [%o]','','','','','','',-10000,10000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,129,'reach','wall_roughness','wall_roughness','Wandrauhigkeit','K_COLEBROOK','zzz_Wandrauhigkeit','rugozitate_perete','yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb)','[mm]','[mm]','[mm]',ARRAY['Werkinformation']::qgep_od.plantype[],'true','decimal(5,2)','[mm]','roughness coefficient after Prandtl Colebrook (ks), unit milimeter [mm]','[mm]','Wandrauhigkeitsbeiwert nach Prandtl Colebrook (ks), Milimeter [mm]','','','','','','',0,100); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','swmm_default_coefficient_of_friction','swmm_default_coefficient_of_friction',NULL,NULL,NULL,NULL,'Default coefficient of friction for SWMM export.',NULL,NULL,NULL,NULL,NULL,'true','smallint','[m^(1/3)/s]','Manning-Strickler [m^(1/3)/s]','[m^(1/3)/s]','Manning-Strickler [m^(1/3)/s]','','','','','','',0,999); - INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','hydraulic_load','hydraulic_load',NULL,NULL,NULL,NULL,'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].',NULL,NULL,NULL,'true','decimal(7,3)','[%]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','','','','','','',0,100); + INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (31,9999999,'reach','dss2020_hydraulic_load_current','dss2020_hydraulic_load_current',NULL,NULL,NULL,NULL,'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%].','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].',NULL,NULL,NULL,'true','decimal(7,3)','[%]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','[m^(1/3)/s]','Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%].','','','','','','',0,100); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3558,'param_ca_general','dry_wheather_flow','dry_wheather_flow','Trockenwetteranfall','DEBIT_TEMPS_SEC','zzz_Trockenwetteranfall','fluxul_de_vreme_uscata','Dry wheather flow','NULL','[l/s]','[l/s]','[l/s]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(9,3)','[l/s]','liters per second [l/s]','[l/s]','Liter pro Sekunde [l/s]','','','','','','',0,100000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3195,'param_ca_general','flow_path_length','flow_path_length','Fliessweglaenge','L_LIGNE_ECOULEMENT','zzz_Fliessweglaenge','lungimea_traseului_de_curgere','Length of flow path','Fliessweglänge','[m]','[m]','[m]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','decimal(7,2)','[m]','meter [m], 2 decimal digits','[m]','Meter [m], 2 Dezimalstellen','','','','','','',0,30000); INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (3189,3194,'param_ca_general','flow_path_slope','flow_path_slope','Fliessweggefaelle','P_LIGNE_ECOULEMENT','zzz_Fliessweggefaelle','panta_traseului_de_curgere','Slope of flow path [%o]','Fliessweggefälle [%o]','[%o]','[%o]','[%o]',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','smallint','[%o]','permill [%]','[%o]','Promille [%o]','','','','','','',0,1000); diff --git a/delta/delta_1.5.8_add_reach_hydraulic_load.sql b/delta/delta_1.5.8_add_reach_hydraulic_load.sql index 2f07a665b..ec2061b41 100644 --- a/delta/delta_1.5.8_add_reach_hydraulic_load.sql +++ b/delta/delta_1.5.8_add_reach_hydraulic_load.sql @@ -1,2 +1,2 @@ -ALTER TABLE qgep_od.reach ADD COLUMN hydraulic_load decimal(7,3) ; -COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%%].'; \ No newline at end of file +ALTER TABLE qgep_od.reach ADD COLUMN dss2020_hydraulic_load_current smallint; +COMMENT ON COLUMN qgep_od.reach.dss2020_hydraulic_load_current IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%%].'; \ No newline at end of file diff --git a/test/test_swmm.py b/test/test_swmm.py index db02f6481..800b49895 100644 --- a/test/test_swmm.py +++ b/test/test_swmm.py @@ -23,65 +23,65 @@ def setUp(cls): pgservice=os.environ.get('PGSERVICE') or 'pg_qgep' cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) - # def test_count_vw_aquifers(self): - # self.assert_count("vw_aquifers", "qgep_swmm", 0) + def test_count_vw_aquifers(self): + self.assert_count("vw_aquifers", "qgep_swmm", 0) - # def test_count_vw_conduits(self): - # self.assert_count("vw_conduits", "qgep_swmm", 5095) + def test_count_vw_conduits(self): + self.assert_count("vw_conduits", "qgep_swmm", 5095) - # def test_count_vw_coordinates(self): - # self.assert_count("vw_coordinates", "qgep_swmm", 6686) + def test_count_vw_coordinates(self): + self.assert_count("vw_coordinates", "qgep_swmm", 6686) - # def test_count_vw_coverages(self): - # self.assert_count("vw_coverages", "qgep_swmm", 0) + def test_count_vw_coverages(self): + self.assert_count("vw_coverages", "qgep_swmm", 0) - # def test_count_vw_dividers(self): - # self.assert_count("vw_dividers", "qgep_swmm", 41) + def test_count_vw_dividers(self): + self.assert_count("vw_dividers", "qgep_swmm", 41) - # def test_count_vw_dwf(self): - # self.assert_count("vw_dwf", "qgep_swmm", 1352) + def test_count_vw_dwf(self): + self.assert_count("vw_dwf", "qgep_swmm", 1352) - # def test_count_vw_infiltration(self): - # self.assert_count("vw_infiltration", "qgep_swmm", 1352) + def test_count_vw_infiltration(self): + self.assert_count("vw_infiltration", "qgep_swmm", 1352) - # def test_count_vw_junctions(self): - # self.assert_count("vw_junctions", "qgep_swmm", 4575) + def test_count_vw_junctions(self): + self.assert_count("vw_junctions", "qgep_swmm", 4575) - # def test_count_vw_landuses(self): - # self.assert_count("vw_landuses", "qgep_swmm", 6) + def test_count_vw_landuses(self): + self.assert_count("vw_landuses", "qgep_swmm", 6) - # def test_count_vw_losses(self): - # self.assert_count("vw_losses", "qgep_swmm", 1053) + def test_count_vw_losses(self): + self.assert_count("vw_losses", "qgep_swmm", 1053) - # def test_count_vw_outfalls(self): - # self.assert_count("vw_outfalls", "qgep_swmm", 54) + def test_count_vw_outfalls(self): + self.assert_count("vw_outfalls", "qgep_swmm", 54) - # def test_count_vw_polygons(self): - # self.assert_count("vw_polygons", "qgep_swmm", 27405) + def test_count_vw_polygons(self): + self.assert_count("vw_polygons", "qgep_swmm", 27405) - # def test_count_vw_pumps(self): - # self.assert_count("vw_pumps", "qgep_swmm", 0) + def test_count_vw_pumps(self): + self.assert_count("vw_pumps", "qgep_swmm", 0) - # def test_count_vw_raingages(self): - # self.assert_count("vw_raingages", "qgep_swmm", 2035) + def test_count_vw_raingages(self): + self.assert_count("vw_raingages", "qgep_swmm", 2035) - # def test_count_vw_storages(self): - # self.assert_count("vw_storages", "qgep_swmm", 23) + def test_count_vw_storages(self): + self.assert_count("vw_storages", "qgep_swmm", 23) - # def test_count_vw_subareas(self): - # self.assert_count("vw_subareas", "qgep_swmm", 2035) + def test_count_vw_subareas(self): + self.assert_count("vw_subareas", "qgep_swmm", 2035) - # def test_count_vw_subcatchments(self): - # self.assert_count("vw_subcatchments", "qgep_swmm", 2035) + def test_count_vw_subcatchments(self): + self.assert_count("vw_subcatchments", "qgep_swmm", 2035) - # def test_count_vw_tags(self): - # self.assert_count("vw_tags", "qgep_swmm", 11782) + def test_count_vw_tags(self): + self.assert_count("vw_tags", "qgep_swmm", 11782) - # def test_count_vw_vertices(self): - # self.assert_count("vw_vertices", "qgep_swmm", 2854) + def test_count_vw_vertices(self): + self.assert_count("vw_vertices", "qgep_swmm", 2854) - # def test_count_vw_xsections(self): - # self.assert_count("vw_xsections", "qgep_swmm", 5095) + def test_count_vw_xsections(self): + self.assert_count("vw_xsections", "qgep_swmm", 5095) if __name__ == '__main__': unittest.main() From bf6e06fc51ad8e1cbf473fbe0a67867644f6d0ea Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 15 Dec 2022 08:43:18 +0100 Subject: [PATCH 37/39] Sjb remarks --- 03_qgep_db_dss.sql | 4 ---- 05_data_model_extensions.sql | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index daa56f905..d0637727b 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -1887,8 +1887,6 @@ ALTER TABLE qgep_od.reach ADD COLUMN clear_height integer ; COMMENT ON COLUMN qgep_od.reach.clear_height IS 'Maximal height (inside) of profile / Maximale Innenhöhe des Kanalprofiles / Hauteur intérieure maximale du profil'; ALTER TABLE qgep_od.reach ADD COLUMN coefficient_of_friction smallint ; COMMENT ON COLUMN qgep_od.reach.coefficient_of_friction IS 'yyy http://www.linguee.com/english-german/search?source=auto&query=reibungsbeiwert / Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Manning-Strickler (K oder kstr) / Constante de rugosité selon Manning-Strickler (K ou kstr)'; -ALTER TABLE qgep_od.reach ADD COLUMN swmm_default_coefficient_of_friction smallint ; -COMMENT ON COLUMN qgep_od.reach.swmm_default_coefficient_of_friction IS '1 / N_Manning, value between 0 and 999. Value exported in SWMM if coefficient_of_friction and wall_roughness are not set. '; ALTER TABLE qgep_od.reach ADD COLUMN elevation_determination integer ; COMMENT ON COLUMN qgep_od.reach.elevation_determination IS 'yyy_Definiert die Hoehenbestimmung einer Haltung. / Definiert die Hoehenbestimmung einer Haltung. / Définition de la détermination altimétrique d''un tronçon.'; ALTER TABLE qgep_od.reach ADD COLUMN horizontal_positioning integer ; @@ -1916,8 +1914,6 @@ ALTER TABLE qgep_od.reach ADD COLUMN slope_building_plan smallint ; COMMENT ON COLUMN qgep_od.reach.slope_building_plan IS 'yyy_Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen. / Auf dem alten Plan eingezeichnetes Plangefälle [%o]. Nicht kontrolliert im Feld. Kann nicht für die hydraulische Berechnungen übernommen werden. Für Liegenschaftsentwässerung und Meliorationsleitungen. Darstellung als z.B. 3.5%oP auf Plänen. / Pente indiquée sur d''anciens plans non contrôlée [%o]. Ne peut pas être reprise pour des calculs hydrauliques. Indication pour des canalisations de biens-fonds ou d''amélioration foncière. Représentation sur de plan: 3.5‰ p'; ALTER TABLE qgep_od.reach ADD COLUMN wall_roughness decimal(5,2) ; COMMENT ON COLUMN qgep_od.reach.wall_roughness IS 'yyy Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb) / Hydraulische Kenngrösse zur Beschreibung der Beschaffenheit der Kanalwandung. Beiwert für die Formeln nach Prandtl-Colebrook (ks oder kb) / Coefficient de rugosité d''après Prandtl Colebrook (ks ou kb)'; -ALTER TABLE qgep_od.reach ADD COLUMN hydraulic_load decimal(7,3) ; -COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; ------- CREATE TRIGGER diff --git a/05_data_model_extensions.sql b/05_data_model_extensions.sql index 43df4be67..b3adfaa70 100644 --- a/05_data_model_extensions.sql +++ b/05_data_model_extensions.sql @@ -80,8 +80,19 @@ added solely for QGEP has to be updated by triggers'; --- Modifications done for link with SWMM +-- Modifications applied for link with SWMM ALTER TABLE qgep_od.reach ADD COLUMN swmm_default_coefficient_of_friction smallint ; COMMENT ON COLUMN qgep_od.reach.swmm_default_coefficient_of_friction IS '1 / N_Manning, value between 0 and 999. Value exported in SWMM if coefficient_of_friction and wall_roughness are not set. '; ALTER TABLE qgep_od.reach ADD COLUMN dss2020_hydraulic_load_current smallint ; -COMMENT ON COLUMN qgep_od.reach.hydraulic_load IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%]. / Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; +COMMENT ON COLUMN qgep_od.reach.dss2020_hydraulic_load_current IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%]. / Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; + +CREATE TABLE qgep_swmm.reach_coefficient_of_friction (fk_material integer, coefficient_of_friction smallint); +ALTER TABLE qgep_swmm.reach_coefficient_of_friction ADD CONSTRAINT pkey_qgep_vl_reach_coefficient_of_friction_id PRIMARY KEY (fk_material); +INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) SELECT vsacode FROM qgep_vl.reach_material; +UPDATE qgep_swmm.reach_coefficient_of_friction SET coefficient_of_friction = (CASE WHEN fk_material IN (5381,5081,3016) THEN 100 + WHEN fk_material IN (2754,3638,3639,3640,3641,3256,147,148,3648,5079,5080,153,2762) THEN 83 + WHEN fk_material IN (2755) THEN 67 + WHEN fk_material IN (5076,5077,5078,5382) THEN 111 + WHEN fk_material IN (3654) THEN 91 + WHEN fk_material IN (154,2761) THEN 71 + ELSE 100 END); \ No newline at end of file From aff96a84fea456cbee5d4155312a92ac3b00dfe1 Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 15 Dec 2022 08:48:35 +0100 Subject: [PATCH 38/39] Sjb remarks --- 05_data_model_extensions.sql | 5 +++++ swmm_views/01_vw_swmm_create_schema.sql | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/05_data_model_extensions.sql b/05_data_model_extensions.sql index b3adfaa70..b0915bb41 100644 --- a/05_data_model_extensions.sql +++ b/05_data_model_extensions.sql @@ -81,11 +81,16 @@ has to be updated by triggers'; -- Modifications applied for link with SWMM +------------------------------------------- + +-- Add attributes ALTER TABLE qgep_od.reach ADD COLUMN swmm_default_coefficient_of_friction smallint ; COMMENT ON COLUMN qgep_od.reach.swmm_default_coefficient_of_friction IS '1 / N_Manning, value between 0 and 999. Value exported in SWMM if coefficient_of_friction and wall_roughness are not set. '; ALTER TABLE qgep_od.reach ADD COLUMN dss2020_hydraulic_load_current smallint ; COMMENT ON COLUMN qgep_od.reach.dss2020_hydraulic_load_current IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%]. / Dimensionierungsabfluss geteilt durch Normalabflusskapazität der Leitung [%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%].'; +-- Add table for defaults coefficients of friction +CREATE SCHEMA IF NOT EXISTS qgep_swmm; CREATE TABLE qgep_swmm.reach_coefficient_of_friction (fk_material integer, coefficient_of_friction smallint); ALTER TABLE qgep_swmm.reach_coefficient_of_friction ADD CONSTRAINT pkey_qgep_vl_reach_coefficient_of_friction_id PRIMARY KEY (fk_material); INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) SELECT vsacode FROM qgep_vl.reach_material; diff --git a/swmm_views/01_vw_swmm_create_schema.sql b/swmm_views/01_vw_swmm_create_schema.sql index e2cf8af1b..84c36866b 100644 --- a/swmm_views/01_vw_swmm_create_schema.sql +++ b/swmm_views/01_vw_swmm_create_schema.sql @@ -1,2 +1 @@ -DROP SCHEMA IF EXISTS qgep_swmm CASCADE; CREATE SCHEMA IF NOT EXISTS qgep_swmm; \ No newline at end of file From 4fe6d0b9103ef7ba7c36f02bd426d9961328fe17 Mon Sep 17 00:00:00 2001 From: Produit Date: Thu, 15 Dec 2022 08:58:23 +0100 Subject: [PATCH 39/39] update tests with new counts --- test/test_swmm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test_swmm.py b/test/test_swmm.py index 800b49895..8fa2ad35b 100644 --- a/test/test_swmm.py +++ b/test/test_swmm.py @@ -30,28 +30,28 @@ def test_count_vw_conduits(self): self.assert_count("vw_conduits", "qgep_swmm", 5095) def test_count_vw_coordinates(self): - self.assert_count("vw_coordinates", "qgep_swmm", 6686) + self.assert_count("vw_coordinates", "qgep_swmm", 8044) def test_count_vw_coverages(self): self.assert_count("vw_coverages", "qgep_swmm", 0) def test_count_vw_dividers(self): - self.assert_count("vw_dividers", "qgep_swmm", 41) + self.assert_count("vw_dividers", "qgep_swmm", 45) def test_count_vw_dwf(self): - self.assert_count("vw_dwf", "qgep_swmm", 1352) + self.assert_count("vw_dwf", "qgep_swmm", 2035) def test_count_vw_infiltration(self): self.assert_count("vw_infiltration", "qgep_swmm", 1352) def test_count_vw_junctions(self): - self.assert_count("vw_junctions", "qgep_swmm", 4575) + self.assert_count("vw_junctions", "qgep_swmm", 5864) def test_count_vw_landuses(self): self.assert_count("vw_landuses", "qgep_swmm", 6) def test_count_vw_losses(self): - self.assert_count("vw_losses", "qgep_swmm", 1053) + self.assert_count("vw_losses", "qgep_swmm", 5095) def test_count_vw_outfalls(self): self.assert_count("vw_outfalls", "qgep_swmm", 54) @@ -66,7 +66,7 @@ def test_count_vw_raingages(self): self.assert_count("vw_raingages", "qgep_swmm", 2035) def test_count_vw_storages(self): - self.assert_count("vw_storages", "qgep_swmm", 23) + self.assert_count("vw_storages", "qgep_swmm", 46) def test_count_vw_subareas(self): self.assert_count("vw_subareas", "qgep_swmm", 2035) @@ -75,7 +75,7 @@ def test_count_vw_subcatchments(self): self.assert_count("vw_subcatchments", "qgep_swmm", 2035) def test_count_vw_tags(self): - self.assert_count("vw_tags", "qgep_swmm", 11782) + self.assert_count("vw_tags", "qgep_swmm", 13094) def test_count_vw_vertices(self): self.assert_count("vw_vertices", "qgep_swmm", 2854)