diff --git a/delta/delta_1.6.0_noop.sql b/delta/delta_1.6.0_noop.sql deleted file mode 100644 index f97ae929..00000000 --- a/delta/delta_1.6.0_noop.sql +++ /dev/null @@ -1,2 +0,0 @@ --- noop delta, used only to unambigously define the datamodel version -SELECT 1; diff --git a/delta/delta_1.6.2_adapt_swmm_views.sql b/delta/delta_1.6.2_adapt_swmm_views.sql new file mode 100644 index 00000000..96fe19c2 --- /dev/null +++ b/delta/delta_1.6.2_adapt_swmm_views.sql @@ -0,0 +1,4 @@ +-------- +-- Corrections to swmm views 12_vw_swmm_raingages, 08_vw_swmm_outfalls, 02_vw_swmm_junctions and 23_vw_swmm_xsections +-------- +SELECT 1; diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index bd3ce9cf..2bc8a10a 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -8,9 +8,9 @@ SELECT wn.obj_id as Name, coalesce(wn.bottom_level,0) as InvertElev, (co.level-wn.bottom_level) as MaxDepth, - NULL::float as InitDepth, - NULL::float as SurchargeDepth, - NULL::float as PondedArea, + 0.0::float as InitDepth, -- default set to 0 instead of NULL + 0.0::float as SurchargeDepth, -- default set to 0 instead of NULL + 0.0::float as PondedArea, -- default set to 0 instead of NULL ws.identifier::text as description, CONCAT_WS(',', 'manhole', mf.value_en) as tag, wn.situation_geometry as geom, @@ -41,9 +41,9 @@ SELECT wn.obj_id as Name, coalesce(wn.bottom_level,0) as InvertElev, (co.level-wn.bottom_level) as MaxDepth, - NULL::float as InitDepth, - NULL::float as SurchargeDepth, - NULL::float as PondedArea, + 0.0::float as InitDepth, + 0.0::float as SurchargeDepth, + 0.0::float as PondedArea, ws.identifier::text as description, CONCAT_WS(',','special_structure', ss_fu.value_en) as tag, wn.situation_geometry as geom, @@ -106,9 +106,9 @@ SELECT 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, + 0.0::float as InitDepth, + 0.0::float as SurchargeDepth, + 0.0::float as PondedArea, coalesce(from_wn.obj_id, concat('from_node@',re.obj_id)) as description, 'junction without structure' as tag, coalesce(from_wn.situation_geometry, ST_StartPoint(re.progression_geometry)) as geom, @@ -142,9 +142,9 @@ SELECT 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, + 0.0::float as InitDepth, + 0.0::float as SurchargeDepth, + 0.0::float as PondedArea, coalesce(to_wn.obj_id, concat('to_node@',re.obj_id)) as description, 'junction without structure' as tag, coalesce(to_wn.situation_geometry, ST_EndPoint(re.progression_geometry)) as geom, diff --git a/swmm_views/08_vw_swmm_outfalls.sql b/swmm_views/08_vw_swmm_outfalls.sql index 0017eac6..1e23b223 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -6,28 +6,36 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_outfalls AS SELECT wn.obj_id as Name, coalesce(wn.bottom_level,0) as InvertElev, - 'FREE'::varchar as Type, - NULL as StageData, +-- 'FREE'::varchar as Type, + CASE + WHEN dp.waterlevel_hydraulic IS NOT NULL THEN 'FIXED' + ELSE 'FREE' + END as Type, -- Type of outfall boundary condition: FREE: outfall stage determined by minimum of critical flow depth and normal flow depth in the connecting conduit. NORMAL: outfall stage based on normal flow depth in the connecting conduit. FIXED: outfall stage set to a fixed value. TIDAL: outfall stage given by a table of tide elevation versus time of day. TIMESERIES: outfall stage supplied from a time series of elevations +-- 0 as StageData, + CASE + WHEN dp.waterlevel_hydraulic IS NOT NULL THEN dp.waterlevel_hydraulic + ELSE 0 + END as StageData, 'NO'::varchar as tide_gate, - NULL::varchar as RouteTo, + '0'::varchar as RouteTo, ws.identifier as description, dp.obj_id::varchar as tag, wn.situation_geometry as geom, - CASE - WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' - ELSE 'current' - END as state, CASE - WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' - ELSE 'secondary' - END as hierarchy, - wn.obj_id as obj_id + WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' + ELSE 'current' + END as state, + CASE + WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' + ELSE 'secondary' + END as hierarchy, + wn.obj_id as obj_id FROM qgep_od.discharge_point as dp LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = dp.obj_id::text -LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code -LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE wn.obj_id IS NOT NULL AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) @@ -36,10 +44,10 @@ UNION SELECT wn.obj_id as Name, coalesce(wn.bottom_level,0) as InvertElev, - 'FREE'::varchar as Type, - NULL as StageData, + 'FREE' as Type, -- Type of outfall boundary condition: FREE: outfall stage determined by minimum of critical flow depth and normal flow depth in the connecting conduit. NORMAL: outfall stage based on normal flow depth in the connecting conduit. FIXED: outfall stage set to a fixed value. TIDAL: outfall stage given by a table of tide elevation versus time of day. TIMESERIES: outfall stage supplied from a time series of elevations + 0 as StageData, 'NO'::varchar as tide_gate, - NULL::varchar as RouteTo, + '0'::varchar as RouteTo, ws.identifier as description, ii.obj_id::varchar as tag, wn.situation_geometry as geom, @@ -52,12 +60,13 @@ SELECT ELSE 'secondary' END as hierarchy, wn.obj_id as obj_id + FROM qgep_od.infiltration_installation as ii LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id::text = ii.obj_id::text -LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code -LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id +LEFT JOIN qgep_vl.wastewater_structure_status ws_st ON ws.status = ws_st.code +LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE wn.obj_id IS NOT NULL AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) ; diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index 9257254a..e02a2d0b 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -20,10 +20,10 @@ SELECT ELSE (ca.surface_area::numeric)::double precision END AS Area, CASE - WHEN state = 'rw_current' then discharge_coefficient_rw_current - WHEN state = 'rw_planned' then discharge_coefficient_rw_planned - WHEN state = 'ww_current' then discharge_coefficient_ww_current - WHEN state = 'ww_planned' then discharge_coefficient_ww_planned + WHEN state = 'rw_current' AND discharge_coefficient_rw_current IS NOT NULL then discharge_coefficient_rw_current + WHEN state = 'rw_planned' AND discharge_coefficient_rw_planned IS NOT NULL then discharge_coefficient_rw_planned + WHEN state = 'ww_current' AND discharge_coefficient_ww_current IS NOT NULL then discharge_coefficient_ww_current + WHEN state = 'ww_planned' AND discharge_coefficient_ww_planned IS NOT NULL then discharge_coefficient_ww_planned ELSE 0 END as percImperv, -- take from catchment_area instead of default value CASE @@ -41,7 +41,7 @@ SELECT END as Width, -- Width of overland flow path estimation 0.5 as percSlope, -- default value 0 as CurbLen, -- default value - NULL::varchar as SnowPack, -- default value + 'default_snow_pack'::varchar as SnowPack, -- default value CASE WHEN fk_wastewater_networkelement_ww_current is not null THEN diff --git a/swmm_views/12_vw_swmm_raingages.sql b/swmm_views/12_vw_swmm_raingages.sql index cfdac4cc..c17c3f37 100644 --- a/swmm_views/12_vw_swmm_raingages.sql +++ b/swmm_views/12_vw_swmm_raingages.sql @@ -2,10 +2,10 @@ 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, + 'INTENSITY'::varchar as Format, -- Format in which the rain data are supplied: INTENSITY: each rainfall value is an average rate in inches/hour (or mm/hour) over the recording interval. VOLUME: each rainfall value is the volume of rain that fell in the recording interval (in inches or millimeters). CUMULATIVE: each rainfall value represents the cumulative rainfall that has occurred since the start of the last series of non-zero values (in inches or millimeters). + '0:15'::varchar as Interval, -- Recording time interval between gage readings in decimal hours or hours:minutes format. + '1.0'::varchar as SCF, -- Snow Catch Factor Factor that corrects gage readings for snowfall. + 'TIMESERIES default_qgep_raingage_timeserie'::varchar as Source, -- Source of rainfall data; either TIMESERIES for user-defined time series data or FILE for an external data file. see Rain Gage Properties of SWMM Documentation for furhter information. st_centroid(perimeter_geometry)::geometry(Point, %(SRID)s) as geom, state, CASE diff --git a/swmm_views/23_vw_swmm_xsections.sql b/swmm_views/23_vw_swmm_xsections.sql index 33774607..842a3046 100644 --- a/swmm_views/23_vw_swmm_xsections.sql +++ b/swmm_views/23_vw_swmm_xsections.sql @@ -31,13 +31,13 @@ SELECT DISTINCT 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 + ELSE 0 -- default set to 0 instead of NULL END as Geom2, --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, - NULL as Culvert, + 0 as Culvert, -- default set to 0 instead of NULL CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current'