osmc:CM/SQL: mudanças entre as edições
Linha 13: | Linha 13: | ||
<syntaxhighlight lang="sql"> | <syntaxhighlight lang="sql"> | ||
CREATE TABLE grid_cm.l0 AS | DROP TABLE IF EXISTS grid_cm.l0 | ||
; | |||
CREATE TABLE grid_cm.l0 ( | |||
LIKE osmc.tflike_decode_scientific_absolute_geoms | |||
INCLUDING ALL | |||
); | |||
INSERT INTO grid_cm.l0 AS | |||
SELECT * | SELECT * | ||
FROM osmc.decode_scientific_absolute_geoms(' | FROM osmc.decode_scientific_absolute_geoms( | ||
; | '1,2,3,4,5,6,7,8,9,a,b,c,d', | ||
'CM', | |||
16 | |||
); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
A lista de de geocódigos é conhecida, faz parte da configuração do país, fixada no [https://git.afa.codes/CM/blob/main/conf.yaml#L37 git oficial do país], como ''grid_l0_cell_sci_base''. | |||
A tabela gerada tem a seguinte estrutura: | |||
<pre> | |||
Column | Type | Description | |||
----------------+----------+------------------- | |||
code | text | Geocode, withoutout the country prefix. | |||
area | real | Area in squared meters | |||
side | real | Cell side size, in meters | |||
truncated_code | text | ? | |||
base | text | ? | |||
geom | geometry | Original geometri, in the native SRID projection. | |||
geom4326 | geometry | Expanded geometry with no projection, with more points to avoid efeito varal. | |||
</pre> |
Edição das 08h03min de 5 de junho de 2024
Documentação do processo SQL de geração das grades em Camarões, detalhando o apresentado em osmc:Metodologia/Algoritmo SQL.
Teste online
A visualização Web é oferecida no site AFAcodes, por exemplo as células 8a, 8b e 9 são visualizadas por https://afa.codes/CM+8a,8b,9
. São construídas pelo endpoint https://afa.codes/geo:osmcodes:CM+{codigos}.json
. Por exemplo https://afa.codes/geo:osmcodes:CM+8a,8b,9.json
.
No NGINX o endpoint redireciona a solicitação para o PostgreSQL através do PostgREST, no SQL-schema api
. No exemplo é utilizada a chamada api.osmcode_decode_scientific_absolute('8a,8b,9','CM',18)
. Maiores detalhes sobre a API em osmc:Api.
As funções API trabalham apenas com JSON. A função equivalente porém retornando dados SQL seria osmc.decode_scientific_absolute_geoms('8a,8b,9','CM',18)
, que discutimos neste artigo Wiki.
Grade L0
A grade L0 de células inteiras e respectivos rótulos, ilustrada ao lado, foi gerada por:
DROP TABLE IF EXISTS grid_cm.l0
;
CREATE TABLE grid_cm.l0 (
LIKE osmc.tflike_decode_scientific_absolute_geoms
INCLUDING ALL
);
INSERT INTO grid_cm.l0 AS
SELECT *
FROM osmc.decode_scientific_absolute_geoms(
'1,2,3,4,5,6,7,8,9,a,b,c,d',
'CM',
16
);
A lista de de geocódigos é conhecida, faz parte da configuração do país, fixada no git oficial do país, como grid_l0_cell_sci_base.
A tabela gerada tem a seguinte estrutura:
Column | Type | Description ----------------+----------+------------------- code | text | Geocode, withoutout the country prefix. area | real | Area in squared meters side | real | Cell side size, in meters truncated_code | text | ? base | text | ? geom | geometry | Original geometri, in the native SRID projection. geom4326 | geometry | Expanded geometry with no projection, with more points to avoid efeito varal.