osmc:CM/SQL: mudanças entre as edições

Linha 44: Linha 44:


Os recortes podem ser obtidos pela função de recortes por jurisdição, ''osmc.grid_jurisdiction_cutcells''(), que faz simplesmente o ST_Intersect da geometria da jurisdição com as células.
Os recortes podem ser obtidos pela função de recortes por jurisdição, ''osmc.grid_jurisdiction_cutcells''(), que faz simplesmente o ST_Intersect da geometria da jurisdição com as células.
==Grade L1==
[[Arquivo:Grid-CM-L0.png|miniaturadaimagem|280px|Grade scientífica nível ''L1''.]]
rascunho A grade ''L1'' de células inteiras e respectivos rótulos, ilustrada ao lado, foi gerada por:
<syntaxhighlight lang="sql">
-- geração da sequencia completa das demais coberturas candidatas:
select array_agg(i||j) from unnest('{1,2,3,4,5,6,7,8,9,a,b,c,d,e}'::text[]) t1(i), unnest('{h,m,r,v}'::text[]) t2(j);
DROP TABLE IF EXISTS grid_cm.l1
;
CREATE TABLE grid_cm.l1 (
  LIKE osmc.tflike_decode_scientific_absolute_geoms
  INCLUDING ALL
);
INSERT INTO grid_cm.l1 AS
select row_number() over() as gid, *
from (
SELECT 76::bit(10) || (natcod.baseh_to_vbit('0'||lower(code),16)) as cbits,
code as b16_label,
'0'||lower(code)  as prefix, geom
FROM osmc.decode_scientific_absolute_geoms(
'1h,2h,3h,4h,5h,6h,7h,8h,9h,ah,bh,ch,dh,eh,1m,2m,3m,4m,5m,6m,7m,8m,9m,am,bm,cm,dm,em,1r,2r,3r,4r,5r,6r,7r,8r,9r,ar,br,cr,dr,er,1v,2v,3v,4v,5v,6v,7v,8v,9v,av,bv,cv,dv,ev'
,'CM',16)
    where st_intersects(geom, st_transform((select geom from  optim.jurisdiction_geom where isolabel_ext='BR'),952019) )
) t3
;
</syntaxhighlight>
2 384

edições