forked from smart-facility/cognicity-schema
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #42 from urbanriskmap/dev
Merge dev to form v3.0.6
- Loading branch information
Showing
10 changed files
with
2,815 additions
and
2,705 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Appends new district ID to report properties of existing reports (Indonesia only) | ||
|
||
-- Update the local areas table with the new key (internally generated) | ||
UPDATE cognicity.local_areas SET district_id = (substring(geom_id::varchar, 1,4))::int; | ||
|
||
-- Set district_id null across all reports | ||
UPDATE cognicity.all_reports SET tags = b.tags FROM (SELECT tags::jsonb || '{"district_id":null}'::jsonb as tags, pkey from cognicity.all_reports) AS b WHERE cognicity.all_reports.pkey = b.pkey; | ||
|
||
-- Set district_id based on local_area | ||
UPDATE cognicity.all_reports SET tags = b.tags FROM (SELECT tags::jsonb || ('{"district_id":"' || j.district_id::varchar || '"}')::jsonb as tags, i.pkey from cognicity.all_reports i, cognicity.local_areas j WHERE ST_WITHIN(i.the_geom, j.the_geom) ) AS b WHERE cognicity.all_reports.pkey = b.pkey; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** Detect if AWS RDS user present and fix permissions if required | ||
Reference: | ||
(1) https://gist.github.com/matthewberryman/7689766b5f94a5499d8c | ||
**/ | ||
CREATE OR REPLACE FUNCTION set_rds_postgis_permissions() | ||
RETURNS VOID AS $$ | ||
DECLARE rds INTEGER; | ||
BEGIN | ||
-- if user rdsadmin exists assume this is an AWS RDS instance | ||
SELECT INTO rds count(*) FROM pg_user WHERE usename = 'rdsadmin'; | ||
IF rds > 0 THEN | ||
ALTER SCHEMA tiger owner to rds_superuser; | ||
ALTER SCHEMA topology owner to rds_superuser; | ||
|
||
CREATE OR REPLACE FUNCTION exec(text) returns text language plpgsql volatile AS $f$ BEGIN EXECUTE $1; RETURN $1; END; $f$; | ||
PERFORM exec('ALTER TABLE ' || quote_ident(s.nspname) || '.' || quote_ident(s.relname) || ' OWNER TO rds_superuser') | ||
FROM ( | ||
SELECT nspname, relname | ||
FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid) | ||
WHERE nspname in ('tiger','topology') AND | ||
relkind IN ('r','S','v') ORDER BY relkind = 'S') | ||
s; | ||
END IF; | ||
RETURN; | ||
END; | ||
$$ LANGUAGE plpgsql VOLATILE | ||
COST 100; | ||
|
||
SELECT * FROM set_rds_postgis_permissions(); |
5,435 changes: 2,734 additions & 2,701 deletions
5,435
data/indonesia/cognicity/local_areas.data.sql
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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