adding tests fro new json returning get methods
This commit is contained in:
@@ -41,42 +41,50 @@ FROM
|
||||
-- -----------|-------
|
||||
-- gini_index | 0.3494
|
||||
|
||||
SELECT * FROM
|
||||
cdb_observatory._OBS_Get(
|
||||
WITH result as (
|
||||
SELECT _OBS_GetJSON::text as expected FROM
|
||||
cdb_observatory._OBS_GetJSON(
|
||||
cdb_observatory._TestPoint(),
|
||||
Array['"us.census.acs".B19083001']::text[],
|
||||
'2009 - 2013',
|
||||
'"us.census.tiger".block_group'
|
||||
);
|
||||
)
|
||||
) select expected = '{"value":0.3494,"name":"Gini Index","tablename":"obs_3e7cc9cfd403b912c57b42d5f9195af9ce2f3cdb","aggregate":"","type":"Numeric","description":""}'
|
||||
from result;
|
||||
|
||||
-- gini index at null island
|
||||
SELECT * FROM
|
||||
cdb_observatory._OBS_Get(
|
||||
WITH result as (
|
||||
SELECT count(_OBS_GetJSON) as expected FROM
|
||||
cdb_observatory._OBS_GetJSON(
|
||||
CDB_LatLng(0, 0),
|
||||
Array['"us.census.acs".B19083001']::text[],
|
||||
'2009 - 2013',
|
||||
'"us.census.tiger".block_group'
|
||||
);
|
||||
|
||||
)
|
||||
) select expected = 0 as OBS_Get_gini_index_at_null_island
|
||||
from result;
|
||||
|
||||
-- OBS_GetPoints
|
||||
-- obs_getpoints
|
||||
-- --------------------
|
||||
-- {4809.33511352425}
|
||||
|
||||
SELECT
|
||||
cdb_observatory._OBS_GetPoints(
|
||||
(cdb_observatory._OBS_GetPoints(
|
||||
cdb_observatory._TestPoint(),
|
||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
||||
);
|
||||
|
||||
(Array['{"colname":"total_pop","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":"sum","name":"Total Population","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'::json])
|
||||
))[1]::text = '{"value":4809.33511352425,"name":"Total Population","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":"sum","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'
|
||||
as OBS_GetPoints_for_test_point;
|
||||
-- what happens at null island
|
||||
|
||||
SELECT
|
||||
cdb_observatory._OBS_GetPoints(
|
||||
(cdb_observatory._OBS_GetPoints(
|
||||
CDB_LatLng(0, 0),
|
||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
||||
);
|
||||
(Array['{"colname":"total_pop","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":"sum","name":"Total Population","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'::json])
|
||||
))[1]::text is null
|
||||
as OBS_GetPoints_for_null_island;
|
||||
|
||||
-- OBS_GetPolygons
|
||||
-- obs_getpolygons
|
||||
@@ -84,19 +92,21 @@ SELECT
|
||||
-- {12996.8172420752}
|
||||
|
||||
SELECT
|
||||
cdb_observatory._OBS_GetPolygons(
|
||||
(cdb_observatory._OBS_GetPolygons(
|
||||
cdb_observatory._TestArea(),
|
||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
||||
);
|
||||
Array['{"colname":"total_pop","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":"sum","name":"Total Population","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'::json]
|
||||
))[1]::text = '{"value":12996.8172420752,"name":"Total Population","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":"sum","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'
|
||||
as OBS_GetPolygons_for_test_point;
|
||||
|
||||
-- see what happens around null island
|
||||
SELECT
|
||||
cdb_observatory._OBS_GetPolygons(
|
||||
(cdb_observatory._OBS_GetPolygons(
|
||||
ST_Buffer(CDB_LatLng(0, 0)::geography, 500)::geometry,
|
||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
||||
);
|
||||
Array['{"colname":"total_pop","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":"sum","name":"Total Population","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'::json])
|
||||
)[1]->>'value' is null
|
||||
as OBS_GetPolygons_for_null_island;
|
||||
|
||||
SELECT * FROM
|
||||
cdb_observatory._OBS_GetSegmentSnapshot(
|
||||
|
||||
Reference in New Issue
Block a user