Skip to content

Commit

Permalink
#1088 add lanesaffectedpattern codes+description
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielwol committed Jan 13, 2025
1 parent a3031de commit 8d7ec93
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

CREATE OR REPLACE FUNCTION itsc_factors.get_lanesaffected_sums(input_string text)
RETURNS TABLE (
lap_descriptions text[],
lane_open_auto integer,
lane_closed_auto integer,
lane_open_bike integer,
Expand All @@ -26,6 +27,7 @@ BEGIN
-- Iterate over the list and aggregate sums for each code
RETURN QUERY
SELECT
ARRAY_AGG(lane_status) AS lap_descriptions,
COALESCE(SUM(lane_open) FILTER (WHERE mode = 'Car'), 0)::int AS lane_open_auto,
COALESCE(SUM(lane_closed) FILTER (WHERE mode = 'Car'), 0)::int AS lane_closed_auto,
COALESCE(SUM(lane_open) FILTER (WHERE mode = 'Bike'), 0)::int AS lane_open_bike,
Expand Down
5 changes: 4 additions & 1 deletion events/construction/sql/create-view-rodars_locations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ SELECT
CASE iil.centreline_id WHEN 0 THEN NULL ELSE iil.centreline_id END AS centreline_id,
centreline_latest.geom AS centreline_geom,
iil.geom AS issue_geom,
iil.linear_name_id,
CASE iil.linear_name_id WHEN 0 THEN NULL ELSE iil.linear_name_id END AS linear_name_id,
iil.lanesaffectedpattern,
lap.lap_descriptions,
lap.lane_open_auto,
lap.lane_closed_auto,
lap.lane_open_bike,
Expand All @@ -79,6 +81,7 @@ LEFT JOIN itsc_factors.roadclosuretype_old
ON iil.roadclosuretype::numeric::integer = itsc_factors.roadclosuretype_old.code,
LATERAL (
SELECT
get_lanesaffected_sums.lap_descriptions,
get_lanesaffected_sums.lane_open_auto,
get_lanesaffected_sums.lane_closed_auto,
get_lanesaffected_sums.lane_open_bike,
Expand Down

0 comments on commit 8d7ec93

Please sign in to comment.