Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions delta/delta_1.6.0_noop.sql

This file was deleted.

4 changes: 4 additions & 0 deletions delta/delta_1.6.2_adapt_swmm_views.sql
Original file line number Diff line number Diff line change
@@ -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;
24 changes: 12 additions & 12 deletions swmm_views/02_vw_swmm_junctions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
45 changes: 27 additions & 18 deletions swmm_views/08_vw_swmm_outfalls.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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)
;
10 changes: 5 additions & 5 deletions swmm_views/09_vw_swmm_subcatchments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions swmm_views/12_vw_swmm_raingages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions swmm_views/23_vw_swmm_xsections.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down