Skip to content

Commit

Permalink
remove support for mine/og restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
smnorris committed Aug 16, 2024
1 parent 14668db commit 2b3e245
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
8 changes: 3 additions & 5 deletions process.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
set -euxo pipefail

# download 250k grid
# load 250k grid
bcdata bc2pg WHSE_BASEMAPPING.NTS_250K_GRID

# load

# create output table
psql $DATABASE_URL -c "DROP TABLE IF EXISTS designations;
CREATE TABLE designations (
Expand All @@ -14,16 +16,12 @@ psql $DATABASE_URL -c "DROP TABLE IF EXISTS designations;
primary_key text,
name text,
harvest_restriction integer,
mine_restriction integer,
og_restriction integer,
indexes_all text[],
aliases_all text[],
descriptions_all text[],
primary_keys_all text[],
names_all text[],
harvest_restrictions_all integer[],
mine_restrictions_all integer[],
og_restrictions_all integer[],
map_tile text,
geom geometry(MULTIPOLYGON, 3005)
);"
Expand Down
18 changes: 0 additions & 18 deletions sql/overlay.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ with tile as (
s.primary_key,
s.name,
s.harvest_restriction,
s.og_restriction,
s.mine_restriction,
CASE
WHEN ST_CoveredBy(s.geom, t.geom) THEN st_makevalid(s.geom)
ELSE st_makevalid((ST_Intersection(s.geom, t.geom, .1)))
Expand All @@ -34,8 +32,6 @@ select
primary_key,
name,
harvest_restriction,
og_restriction,
mine_restriction,
st_makevalid(st_subdivide((st_dump(geom)).geom)) as geom
from tile
) as a where st_dimension(geom) = 2 ; -- do not include any line/point artifacts created by intersect
Expand Down Expand Up @@ -86,8 +82,6 @@ sorted AS
p.primary_key,
p.name,
COALESCE(p.harvest_restriction, 0) as harvest_restriction,
COALESCE(p.mine_restriction, 0) as mine_restriction,
COALESCE(p.og_restriction, 0) as og_restriction,
f.map_tile,
f.geom
FROM flattened f
Expand All @@ -106,8 +100,6 @@ aggregated as (
array_agg(primary_key ORDER BY index) as primary_keys_all,
array_agg(name ORDER BY index) as names_all,
array_agg(harvest_restriction ORDER BY index) as harvest_restrictions_all,
array_agg(mine_restriction ORDER BY index) as mine_restrictions_all,
array_agg(og_restriction ORDER BY index) as og_restrictions_all,
geom
FROM sorted
GROUP BY map_tile, geom
Expand All @@ -120,16 +112,12 @@ INSERT INTO designations (
primary_key,
name,
harvest_restriction,
mine_restriction,
og_restriction,
indexes_all,
aliases_all,
descriptions_all,
primary_keys_all,
names_all,
harvest_restrictions_all,
mine_restrictions_all,
og_restrictions_all,
map_tile,
geom
)
Expand All @@ -140,16 +128,12 @@ SELECT
primary_keys_all[1] as primary_key,
names_all[1] as name,
harvest_restrictions_all[1] as harvest_restriction,
mine_restrictions_all[1] as mine_restriction,
og_restrictions_all[1] as og_restriction,
indexes_all,
aliases_all,
descriptions_all,
primary_keys_all,
names_all,
harvest_restrictions_all,
mine_restrictions_all,
og_restrictions_all,
map_tile,
st_union(geom, .1) as geom
from aggregated
Expand All @@ -160,6 +144,4 @@ group by
primary_keys_all,
names_all,
harvest_restrictions_all,
mine_restrictions_all,
og_restrictions_all,
map_tile;

0 comments on commit 2b3e245

Please sign in to comment.