Wrap functions in row_to_json
This commit is contained in:
parent
ad55625769
commit
077f8fedf5
@ -23,6 +23,14 @@
|
|||||||
-- Creates a table of demographic snapshot
|
-- Creates a table of demographic snapshot
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry, time_span text default '2009 - 2013', geometry_level text default '"us.census.tiger".block_group')
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry, time_span text default '2009 - 2013', geometry_level text default '"us.census.tiger".block_group')
|
||||||
|
RETURNS json
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN row_to_json(cdb_observatory._OBS_GetDemographicSnapshot(geom, time_span, geometry_level));
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetDemographicSnapshot(geom geometry, time_span text default '2009 - 2013', geometry_level text default '"us.census.tiger".block_group' )
|
||||||
RETURNS TABLE(
|
RETURNS TABLE(
|
||||||
total_pop NUMERIC,
|
total_pop NUMERIC,
|
||||||
male_pop NUMERIC,
|
male_pop NUMERIC,
|
||||||
@ -454,7 +462,15 @@ BEGIN
|
|||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION OBS_GetSegmentSnapshot(
|
CREATE OR REPLACE FUNCTION OBS_GetSegmentSnapshot(geom geometry, geometry_level text default '"us.census.tiger".census_tract')
|
||||||
|
RETURNS json
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN row_to_json(cdb_observatory._OBS_GetSegmentSnapshot(geom, geometry_level));
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION _OBS_GetSegmentSnapshot(
|
||||||
geom geometry,
|
geom geometry,
|
||||||
geometry_level text DEFAULT '"us.census.tiger".census_tract'
|
geometry_level text DEFAULT '"us.census.tiger".census_tract'
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
\i test/sql/load_fixtures.sql
|
\i test/sql/load_fixtures.sql
|
||||||
--
|
--
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
cdb_observatory.OBS_GetDemographicSnapshot(
|
cdb_observatory._OBS_GetDemographicSnapshot(
|
||||||
cdb_observatory._TestPoint(),
|
cdb_observatory._TestPoint(),
|
||||||
'2009 - 2013',
|
'2009 - 2013',
|
||||||
'"us.census.tiger".block_group'
|
'"us.census.tiger".block_group'
|
||||||
@ -99,14 +99,14 @@ SELECT
|
|||||||
);
|
);
|
||||||
|
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
cdb_observatory.OBS_GetSegmentSnapshot(
|
cdb_observatory._OBS_GetSegmentSnapshot(
|
||||||
cdb_observatory._TestPoint(),
|
cdb_observatory._TestPoint(),
|
||||||
'"us.census.tiger".census_tract'
|
'"us.census.tiger".census_tract'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- segmentation around null island
|
-- segmentation around null island
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
cdb_observatory.OBS_GetSegmentSnapshot(
|
cdb_observatory._OBS_GetSegmentSnapshot(
|
||||||
CDB_LatLng(0, 0),
|
CDB_LatLng(0, 0),
|
||||||
'"us.census.tiger".census_tract'
|
'"us.census.tiger".census_tract'
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user