first-pass defaults to latest timespan/boundary_id

This commit is contained in:
John Krauss 2016-05-11 18:17:48 -04:00
parent ccf61c3583
commit 506f9ead30
2 changed files with 15 additions and 9 deletions

View File

@ -95,7 +95,8 @@ BEGIN
aggregate, aggregate,
name, name,
type, type,
c.description c.description,
$1 AS boundary_id
FROM column_ids, observatory.OBS_column c, observatory.OBS_column_table ct, observatory.OBS_table t FROM column_ids, observatory.OBS_column c, observatory.OBS_column_table ct, observatory.OBS_table t
WHERE column_ids.column_id = c.id WHERE column_ids.column_id = c.id
AND c.id = ct.column_id AND c.id = ct.column_id

View File

@ -155,20 +155,25 @@ DECLARE
data_table_info json[]; data_table_info json[];
BEGIN BEGIN
geom_table_name := cdb_observatory._OBS_GeomTable(geom, geometry_level);
IF geom_table_name IS NULL
THEN
RAISE NOTICE 'Point % is outside of the data region', ST_AsText(geom);
RETURN QUERY SELECT '{}'::text[], '{}'::NUMERIC[];
END IF;
EXECUTE EXECUTE
'SELECT array_agg(_obs_getcolumndata) 'SELECT array_agg(_obs_getcolumndata)
FROM cdb_observatory._OBS_GetColumnData($1, $2, $3);' FROM cdb_observatory._OBS_GetColumnData($1, $2, $3);'
INTO data_table_info INTO data_table_info
USING geometry_level, column_ids, time_span; USING geometry_level, column_ids, time_span;
IF geometry_level IS NULL THEN
geometry_level = data_table_info[1]->>'boundary_id';
END IF;
geom_table_name := cdb_observatory._OBS_GeomTable(geom, geometry_level);
IF geom_table_name IS NULL
THEN
RAISE NOTICE 'Point % is outside of the data region', ST_AsText(geom);
-- TODO this should return JSON
RETURN QUERY SELECT '{}'::text[], '{}'::NUMERIC[];
END IF;
IF data_table_info IS NULL THEN IF data_table_info IS NULL THEN
RAISE NOTICE 'Cannot find data table for boundary ID %, column_ids %, and time_span %', geometry_level, column_ids, time_span; RAISE NOTICE 'Cannot find data table for boundary ID %, column_ids %, and time_span %', geometry_level, column_ids, time_span;
END IF; END IF;