-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
9 changed files
with
125 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
## Stable | ||
|
||
Projeto em quarententa, aguardando aprovação da comunidade. Neste período estaremos discutindo tudo em https://github.com/OSMBrasil/stable/issues | ||
Projeto em quarententa, aguardando aprovação da comunidade. | ||
Neste período estaremos discutindo tudo em https://github.com/OSMBrasil/stable/issues | ||
|
||
Para auditoria da origem dos dados ou ingestão de novos, ver [`brazil-latest.osm.md`](brazil-latest.osm.md#dump-opensstreetmap-do-brasil). | ||
Para auditoria ou reprodução passo-a-passo do processamento em base de dados SQL, | ||
Para auditoria ou reprodução passo-a-passo do processamento em base de dados SQL, | ||
ver pasta [**src**](src/README.md#software-de-gestão-do-repositório-stable-br). Para justificativas de decisões de projeto, | ||
ver [Rationale.md](Rationale.md). | ||
ver [Rationale.md](docs/Rationale.md). | ||
|
||
Para verificar um exemplo de dados estáveis, ver por exemplo [PR-Curitiba](PR-Curitiba). |
File renamed without changes.
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,14 @@ | ||
|
||
CREATE or replace FUNCTION jsonb_strip_nulls_v2( | ||
p_input jsonb | ||
) RETURNS jsonb AS $f$ | ||
SELECT CASE WHEN x='{}'::JSONb THEN NULL ELSE x END FROM (SELECT jsonb_strip_nulls($1)) t(x) | ||
$f$ LANGUAGE SQL IMMUTABLE; | ||
|
||
|
||
DROP AGGREGATE IF EXISTS array_agg_cat(anyarray) CASCADE; | ||
CREATE AGGREGATE array_agg_cat(anyarray) ( | ||
SFUNC=array_cat, | ||
STYPE=anyarray, | ||
INITCOND='{}' | ||
); |
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,79 @@ | ||
DROP TABLE IF EXISTS stable.member_of CASCADE; | ||
CREATE TABLE stable.member_of( | ||
osm_owner bigint NOT NULL, -- osm_id of a relations | ||
osm_type char(1) NOT NULL, -- from split | ||
osm_id bigint NOT NULL, -- from split | ||
member_type text, | ||
UNIQUE(osm_owner, osm_type, osm_id) | ||
); | ||
CREATE INDEX stb_member_idx ON stable.member_of(osm_type, osm_id); | ||
|
||
--- | ||
|
||
CREATE or replace FUNCTION stable.osm_to_jsonb_remove() RETURNS text[] AS $f$ | ||
SELECT array['osm_uid','osm_user','osm_version','osm_changeset','osm_timestamp']; | ||
$f$ LANGUAGE SQL IMMUTABLE; | ||
|
||
CREATE FUNCTION stable.osm_to_jsonb( | ||
p_input text[], p_strip boolean DEFAULT false | ||
) RETURNS jsonb AS $f$ | ||
SELECT CASE WHEN p_strip THEN jsonb_strip_nulls_v2(x) ELSE x END | ||
FROM ( | ||
SELECT jsonb_object($1) - stable.osm_to_jsonb_remove() | ||
) t(x) | ||
$f$ LANGUAGE sql IMMUTABLE; | ||
|
||
CREATE FUNCTION stable.osm_to_jsonb( | ||
p_input public.hstore, p_strip boolean DEFAULT false | ||
) RETURNS jsonb AS $f$ | ||
SELECT CASE WHEN p_strip THEN jsonb_strip_nulls_v2(x) ELSE x END | ||
FROM ( | ||
SELECT hstore_to_jsonb_loose($1) - stable.osm_to_jsonb_remove() | ||
) t(x) | ||
$f$ LANGUAGE sql IMMUTABLE; | ||
|
||
/*lixo old | ||
CREATE or replace FUNCTION stable.osm_to_jsonb(text[]) RETURNS JSONb AS $f$ | ||
SELECT jsonb_object($1) - stable.osm_to_jsonb_remove() | ||
$f$ LANGUAGE SQL IMMUTABLE; | ||
CREATE or replace FUNCTION stable.osm_to_jsonb(hstore) RETURNS JSONb AS $f$ | ||
SELECT hstore_to_jsonb_loose($1) - stable.osm_to_jsonb_remove() | ||
$f$ LANGUAGE SQL IMMUTABLE; | ||
*/ | ||
|
||
------------ | ||
|
||
ALTER TABLE planet_osm_rels alter column members | ||
type jsonb USING jsonb_object(members) | ||
; -- fazer o com update até estar seguro. Depois trocar por stable.osmmembers_pack(jsonb_object(members)); | ||
|
||
-- demora 15 min: | ||
ALTER TABLE planet_osm_line alter column tags type jsonb USING stable.osm_to_jsonb(tags); | ||
ALTER TABLE planet_osm_ways alter column tags type jsonb | ||
USING jsonb_strip_nulls_v2(stable.osm_to_jsonb(tags)); -- ~10 min | ||
|
||
-- mais rapidos: | ||
ALTER TABLE planet_osm_polygon alter column tags type jsonb USING stable.osm_to_jsonb(tags); | ||
ALTER TABLE planet_osm_rels alter column tags type jsonb USING stable.osm_to_jsonb(tags); | ||
|
||
|
||
-- Opcional LIXO: | ||
/* deu pau, anulando 'name:' ... revisar depois quando for usar. | ||
UPDATE planet_osm_polygon -- ~10 minutos. 4.396.944 linhas. | ||
SET tags = stable.tags_split_prefix(jsonb_strip_nulls_v2(tags)); | ||
UPDATE planet_osm_line -- ~9 minutos. 3.869.230 linhas | ||
SET tags = stable.tags_split_prefix(jsonb_strip_nulls_v2(tags)); | ||
UPDATE planet_osm_rels -- ~1 minuto. 151.288 linhas | ||
SET tags = stable.tags_split_prefix(jsonb_strip_nulls_v2(tags)); | ||
*/ | ||
|
||
UPDATE planet_osm_polygon | ||
SET tags = jsonb_strip_nulls_v2(tags); | ||
UPDATE planet_osm_line | ||
SET tags = jsonb_strip_nulls_v2(tags); | ||
UPDATE planet_osm_rels | ||
SET tags = jsonb_strip_nulls_v2(tags); | ||
|
||
|
||
-- carrega 02-3-lib e CONTINUA N0 04 |
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
File renamed without changes.
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