Skip to content

Instantly share code, notes, and snippets.

@andy-esch
Created November 9, 2017 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy-esch/e189f4b312c21ba4e2098259f5e08842 to your computer and use it in GitHub Desktop.
Save andy-esch/e189f4b312c21ba4e2098259f5e08842 to your computer and use it in GitHub Desktop.
Prototype function for metadata-returning object for cartoframes data_discovery
with envelope as (
SELECT
ST_SetSRID(ST_Extent(the_geom), 4326) as env,
count(*)::int as cnt
FROM
eschbacher.mexican_states
),
numers as (
SELECT
unnest(Array['mx.inegi.entidad', 'mx.inegi.localidad_urbana_y_rural_amanzanada']::text[]) as geom_id,
numer_id
FROM
obs_getavailablenumerators((select env from envelope))
), dataaaaaa as (
SELECT *
FROM (
(
SELECT
OBS_GetMeta(
envelope.env,
json_agg(row_to_json(numers.*)),
10,
1,
envelope.cnt
) AS meta
FROM envelope, numers
GROUP BY envelope.env, envelope.cnt
)
) AS data)
SELECT * FROM json_array_elements((SELECT * from dataaaaaa))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment