-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0d6c84
commit 67ad34d
Showing
1 changed file
with
19 additions
and
14 deletions.
There are no files selected for viewing
33 changes: 19 additions & 14 deletions
33
volumes/short_term_counting_program/sql/artery_assets_objectid.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
CREATE OR REPLACE VIEW traffic.artery_assets | ||
AS | ||
WITH clpav18 AS ( | ||
SELECT | ||
clpav.geo_id, | ||
clpav.objectid, | ||
WITH clpav18 AS ( | ||
SELECT | ||
clpav.geo_id, | ||
clpav.objectid, | ||
row_number() OVER (PARTITION BY clpav.geo_id ORDER BY (SELECT clpav.geo_id)) AS rownumber | ||
FROM gis_shared_streets.centreline_pavement_180430 AS clpav | ||
) | ||
|
||
SELECT | ||
ad.arterycode, | ||
ac.centreline_id, | ||
SELECT | ||
ad.arterycode, | ||
ac.centreline_id, | ||
clpav18.objectid | ||
FROM traffic.arterydata AS ad | ||
JOIN traffic.arteries_centreline AS ac USING (arterycode) | ||
JOIN clpav18 ON clpav18.geo_id = ac.centreline_id AND clpav18.rownumber = 1; | ||
JOIN clpav18 | ||
ON ac.centreline_id = clpav18.geo_id | ||
AND clpav18.rownumber = 1; | ||
|
||
COMMENT ON VIEW traffic.artery_assets IS 'Lookup between artery codes and objectid (to join pavement asset data e.g. vz_analysis.gcc_pavement_asset)'; | ||
ALTER TABLE IF EXISTS traffic.artery_assets | ||
OWNER TO traffic_admins; | ||
COMMENT ON VIEW traffic.artery_assets IS | ||
'Lookup between artery codes and objectid ' | ||
'(to join pavement asset data e.g. vz_analysis.gcc_pavement_asset)'; | ||
|
||
ALTER TABLE IF EXISTS traffic.artery_assets OWNER TO traffic_admins; | ||
|
||
GRANT ALL ON TABLE traffic.artery_assets TO bdit_humans; | ||
GRANT ALL ON TABLE traffic.artery_assets TO traffic_admins; | ||
|
||
|
||
-- flashcrow.counts.arteries_centreline must be migrated to the bigdata.traffic schema and copied over regularly | ||
-- flashcrow.counts.arteries_centreline must be migrated to the bigdata.traffic schema | ||
-- and copied over regularly | ||
-- column arteries_centreline.centreline_id links to column centreline_pavement_180430.geo_id. | ||
-- window function on gis_shared_streets.centreline_pavement_180430 is used to remove duplicates, keeping arterycode unique in the lookup table. | ||
-- window function on gis_shared_streets.centreline_pavement_180430 is used to remove duplicates, | ||
-- keeping arterycode unique in the lookup table. |