-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1571 from cityofaustin/18365-jc-sig-eng-areas
Add new geospatial layers, trigger-managed attribute columns, and a fancy new AGOL helper
- Loading branch information
Showing
77 changed files
with
1,419 additions
and
762 deletions.
There are no files selected for viewing
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
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_cr3_collisions_for_location.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_cr3_mainlane_crash.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_crash_in_jurisdiction.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_crashes_in_jurisdiction.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_location_for_cr3_collision.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_location_for_noncr3_collision.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...base/metadata/databases/default/functions/public_find_noncr3_collisions_for_location.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_find_noncr3_mainlane_crash.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...a/databases/default/functions/public_find_service_road_location_for_centerline_crash.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_get_location_totals.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
database/metadata/databases/default/functions/public_search_atd_location_crashes.yaml
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
database/metadata/databases/default/tables/geo_apd_sectors.yaml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: apd_sectors | ||
schema: geo |
2 changes: 1 addition & 1 deletion
2
...ault/tables/public_atd_jurisdictions.yaml → ...default/tables/geo_atd_jurisdictions.yaml
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,3 +1,3 @@ | ||
table: | ||
name: atd_jurisdictions | ||
schema: public | ||
schema: geo |
2 changes: 1 addition & 1 deletion
2
...ault/tables/public_council_districts.yaml → ...default/tables/geo_council_districts.yaml
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,3 +1,3 @@ | ||
table: | ||
name: council_districts | ||
schema: public | ||
schema: geo |
20 changes: 10 additions & 10 deletions
20
...ault/tables/public_engineering_areas.yaml → ...default/tables/geo_engineering_areas.yaml
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,31 +1,31 @@ | ||
table: | ||
name: engineering_areas | ||
schema: public | ||
schema: geo | ||
select_permissions: | ||
- role: editor | ||
permission: | ||
columns: | ||
- area_id | ||
- label | ||
- updated_at | ||
- engineering_area_id | ||
- atd_engineer_areas | ||
- created_at | ||
- geometry | ||
filter: {} | ||
comment: "" | ||
- role: readonly | ||
permission: | ||
columns: | ||
- area_id | ||
- label | ||
- updated_at | ||
- engineering_area_id | ||
- atd_engineer_areas | ||
- created_at | ||
- geometry | ||
filter: {} | ||
comment: "" | ||
- role: vz-admin | ||
permission: | ||
columns: | ||
- area_id | ||
- label | ||
- updated_at | ||
- engineering_area_id | ||
- atd_engineer_areas | ||
- created_at | ||
- geometry | ||
filter: {} | ||
comment: "" |
2 changes: 1 addition & 1 deletion
2
...fault/tables/public_non_coa_roadways.yaml → .../default/tables/geo_non_coa_roadways.yaml
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,3 +1,3 @@ | ||
table: | ||
name: non_coa_roadways | ||
schema: public | ||
schema: geo |
3 changes: 3 additions & 0 deletions
3
database/metadata/databases/default/tables/geo_signal_engineer_areas.yaml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: signal_engineer_areas | ||
schema: geo |
3 changes: 3 additions & 0 deletions
3
database/metadata/databases/default/tables/geo_zip_codes.yaml
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table: | ||
name: zip_codes | ||
schema: geo |
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
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
3 changes: 3 additions & 0 deletions
3
database/migrations/default/1729529574000_signal_eng_areas/down.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
drop table public.signal_engineer_areas; | ||
|
||
alter table non_coa_roadways add column id serial primary key; |
12 changes: 12 additions & 0 deletions
12
database/migrations/default/1729529574000_signal_eng_areas/up.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
alter table non_coa_roadways drop column id; | ||
|
||
create table public.signal_engineer_areas ( | ||
signal_engineer_area_id integer unique not null, | ||
signal_eng_area text not null, | ||
geometry public.geometry (multipolygon, 4326) not null, | ||
created_at timestamptz default now() not null | ||
); | ||
|
||
create index on signal_engineer_areas using gist (geometry); | ||
|
||
comment on table public.signal_engineer_areas is 'Polygon zones assigned to traffic signal engineers. These zones cover the Full and Limited Purpose juristdiction areas of the City of Austin.'; |
91 changes: 91 additions & 0 deletions
91
database/migrations/default/1729529575000_engineering_areas_edits/down.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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--revert to name updated_at | ||
alter table engineering_areas rename column created_at to updated_at; | ||
--revert time to timestamp with out time zone | ||
alter table engineering_areas alter column updated_at set data type timestamp using updated_at::timestamp; | ||
-- rever other col names | ||
alter table engineering_areas rename column engineering_area_id to area_id; | ||
alter table engineering_areas rename column atd_engineer_areas to label; | ||
|
||
-- revert to `area_id` column | ||
CREATE OR REPLACE FUNCTION public.crashes_set_spatial_attributes() | ||
RETURNS trigger | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
begin | ||
if (new.latitude is not null and new.longitude is not null) then | ||
-- save lat/lon into geometry col | ||
new.position = st_setsrid(st_makepoint(new.longitude, new.latitude), 4326); | ||
-- | ||
-- get location polygon id | ||
-- | ||
if (new.rpt_road_part_id != 2 and upper(ltrim(new.rpt_hwy_num)) in ('35', '183','183A','1','290','71','360','620','45','130')) then | ||
-- use level 5 polygon | ||
new.location_id = ( | ||
select | ||
location_id | ||
from | ||
public.atd_txdot_locations | ||
where | ||
location_group = 2 -- level 5 | ||
and st_contains(geometry, new.position) | ||
limit 1); | ||
else | ||
-- use the other polygons | ||
new.location_id = ( | ||
select | ||
location_id | ||
from | ||
public.atd_txdot_locations | ||
where | ||
location_group = 1 -- not level 5 | ||
and st_contains(geometry, new.position) | ||
limit 1); | ||
end if; | ||
|
||
raise debug 'found location: % compared to previous location: %', new.location_id, old.location_id; | ||
-- | ||
-- check if in austin full purpose jurisdiction | ||
-- | ||
new.in_austin_full_purpose = st_contains((select geometry from atd_jurisdictions where id = 5), new.position); | ||
raise debug 'in austin full purpose: % compared to previous: %', new.in_austin_full_purpose, old.in_austin_full_purpose; | ||
-- | ||
-- get council district | ||
-- | ||
new.council_district = ( | ||
select | ||
council_district | ||
from | ||
public.council_districts | ||
where | ||
st_contains(geometry, new.position) | ||
limit 1); | ||
raise debug 'council_district: % compared to previous: %', new.council_district, old.council_district; | ||
-- | ||
-- get engineering area | ||
-- | ||
new.engineering_area_id = ( | ||
select | ||
area_id | ||
from | ||
public.engineering_areas | ||
where | ||
st_contains(geometry, new.position) | ||
limit 1); | ||
raise debug 'engineering_area_id: % compared to previous: %', new.engineering_area_id, old.engineering_area_id; | ||
else | ||
raise debug 'setting location id and council district to null'; | ||
-- nullify position column | ||
new.position = null; | ||
-- reset location id | ||
new.location_id = null; | ||
-- use city id to determine full purpose jurisdiction | ||
new.in_austin_full_purpose = coalesce(new.rpt_city_id = 22, false); | ||
raise debug 'setting in_austin_full_purpose based on city id: %', new.in_austin_full_purpose; | ||
-- reset council district | ||
new.council_district = null; | ||
-- reset engineering area | ||
new.engineering_area_id = null; | ||
end if; | ||
return new; | ||
end; | ||
$function$ |
Oops, something went wrong.