scratch work to get _obs_columndata to return better defaults
This commit is contained in:
parent
ec1c2f8dfb
commit
9d3bb40877
@ -52,10 +52,17 @@ BEGIN
|
|||||||
EXECUTE '
|
EXECUTE '
|
||||||
WITH geomref AS (
|
WITH geomref AS (
|
||||||
SELECT t.table_id id
|
SELECT t.table_id id
|
||||||
FROM observatory.OBS_column_to_column c2c, observatory.OBS_column_table t
|
FROM observatory.OBS_column_to_column c2c,
|
||||||
|
observatory.OBS_column c,
|
||||||
|
observatory.OBS_column_table geom_ct,
|
||||||
|
observatory.OBS_column_table data_ct,
|
||||||
|
observatory.OBS_table t
|
||||||
WHERE c2c.reltype = ''geom_ref''
|
WHERE c2c.reltype = ''geom_ref''
|
||||||
|
AND c.column_id = c2c.target_id
|
||||||
AND c2c.target_id = $1
|
AND c2c.target_id = $1
|
||||||
AND c2c.source_id = t.column_id
|
AND c2c.source_id = ct.column_id
|
||||||
|
ORDER BY weight DESC
|
||||||
|
LIMIT 1
|
||||||
),
|
),
|
||||||
column_ids as (
|
column_ids as (
|
||||||
select row_number() over () as no, a.column_id as column_id from (select unnest($2) as column_id) a
|
select row_number() over () as no, a.column_id as column_id from (select unnest($2) as column_id) a
|
||||||
|
@ -219,6 +219,7 @@ BEGIN
|
|||||||
|
|
||||||
-- TODO we're assuming our geom_table has only one geom_ref column
|
-- TODO we're assuming our geom_table has only one geom_ref column
|
||||||
-- we *really* should pass in both geom_table_name and boundary_id
|
-- we *really* should pass in both geom_table_name and boundary_id
|
||||||
|
-- TODO tablename should not be passed here (use boundary_id)
|
||||||
EXECUTE
|
EXECUTE
|
||||||
format('SELECT ct.colname
|
format('SELECT ct.colname
|
||||||
FROM observatory.obs_column_to_column c2c,
|
FROM observatory.obs_column_to_column c2c,
|
||||||
@ -284,10 +285,11 @@ BEGIN
|
|||||||
|
|
||||||
query := query || format(' ]::numeric[]
|
query := query || format(' ]::numeric[]
|
||||||
FROM observatory.%I
|
FROM observatory.%I
|
||||||
WHERE %I.geoid = %L
|
WHERE %I.%I = %L
|
||||||
',
|
',
|
||||||
((data_table_info)[1])->>'tablename',
|
((data_table_info)[1])->>'tablename',
|
||||||
((data_table_info)[1])->>'tablename',
|
((data_table_info)[1])->>'tablename',
|
||||||
|
geoid_colname,
|
||||||
geoid
|
geoid
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -332,16 +334,6 @@ DECLARE
|
|||||||
vals NUMERIC[];
|
vals NUMERIC[];
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
IF boundary_id IS NULL THEN
|
|
||||||
-- TODO we should determine best boundary for this geom
|
|
||||||
boundary_id := 'us.census.tiger.block_group';
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF time_span IS NULL THEN
|
|
||||||
-- TODO we should determine latest timespan for this measure
|
|
||||||
time_span := '2010 - 2014';
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF normalize ILIKE 'area' THEN
|
IF normalize ILIKE 'area' THEN
|
||||||
measure_ids := ARRAY[measure_id];
|
measure_ids := ARRAY[measure_id];
|
||||||
ELSIF normalize ILIKE 'denominator' THEN
|
ELSIF normalize ILIKE 'denominator' THEN
|
||||||
|
Loading…
Reference in New Issue
Block a user