test for obs get census

This commit is contained in:
Stuart Lynn
2016-04-25 10:12:43 -04:00
parent 68f5bce80b
commit 07b678e448
2 changed files with 42 additions and 28 deletions
@@ -26,19 +26,19 @@ Done.
9516.27915900609 | 6152.51885204623 | 3363.76030695986 | 28.8 | 5301.51624447348 | 149.500458087105 | 230.000704749392 | 3835.26175169611 | 0 | 0 | 0 | 5681.01740730998 | 3323.51018362871 | 7107.02177675621 | 1040.753188991 | 69.0002114248176 | 793.502431385402 | 327.751004267883 | 2742.7584041365 | 931.502854235037 | 66304 | 0.3494 | 28291 | 3662.76122313407 | 339.251039505353 | 120.750369993431 | 0 | 1764 | 35.3 | 339.251039505353 | 0 | 224.250687130657 | 6549.27006773893 | 327.751004267883 | 28.750088093674 | 201.250616655718 | 621.001902823358 | 373.751145217762 | 1851.5056732326 | 1414.50433420876 | 1115.50341803455 | 615.251885204623 | | 57.500176187348 | 0 | 212.750651893187 | 408.251250930171 | 0 | 155.25047570584 | 109.250334755961 | 92.0002818997568 | 63.2501938060828 | 184.000563799514 | 621.001902823358 | 552.001691398541 | 327.751004267883 | 333.501021886618 | 126.500387612166 | |
(1 row)
dimension | dimension_value
----------------------+-------------------------------------
{total_pop,male_pop} | {9516.27915900609,6152.51885204623}
test_obsgetcensuswithtestpointand2variables
---------------------------------------------
t
(1 row)
dimension | dimension_value
-----------------------+-----------------
{female_pop,male_pop} | {NULL,NULL}
test_obsgetcensuswithnullislandarea
-------------------------------------
t
(1 row)
dimension | dimension_value
-----------------------+-----------------
{female_pop,male_pop} | {}
test_obsgetcensuswithnullisland
---------------------------------
t
(1 row)
obs_get_gini_index_at_test_point
@@ -13,28 +13,42 @@ SELECT * FROM
-- total_pop | 9516.27915900609
-- male_pop | 6152.51885204623
SELECT *
FROM
cdb_observatory._OBS_GetCensus(
cdb_observatory._TestPoint(),
Array['total_pop','male_pop']::text[]
);
WITH result as (
SELECT array_agg(_obs_getcensus->>'value') as b
FROM( select * from
cdb_observatory._OBS_GetCensus(
cdb_observatory._TestPoint(),
Array['total_pop','male_pop']::text[]
)) a
)
select b='{9516.27915900609,6152.51885204623}'
as test_obsGetCensusWithTestPointAnd2Variables
from result;
-- what happens on null island?
-- expect nulls back: {female_pop, male_pop} | {NULL, NULL}
SELECT *
FROM
cdb_observatory._OBS_GetCensus(
ST_Buffer(CDB_LatLng(0, 0)::geography, 5000)::geometry,
Array['female_pop','male_pop']::text[]
);
WITH result as (
SELECT count(vals) non_null
FROM( select _OBS_GetCensus->>'value' vals from
cdb_observatory._OBS_GetCensus(
ST_Buffer(CDB_LatLng(0, 0)::geography, 5000)::geometry,
Array['total_pop','male_pop']::text[]
)) a
)
SELECT non_null = 0 as test_obsGetCensusWithNullIslandArea
FROM result;
-- expect nulls back {female_pop, male_pop} | {NULL, NULL}
SELECT *
FROM
cdb_observatory._OBS_GetCensus(
CDB_LatLng(0, 0),
Array['female_pop', 'male_pop']::text[]
);
WITH result as (
SELECT count(vals) non_null
FROM( select _OBS_GetCensus->>'value' vals from
cdb_observatory._OBS_GetCensus(
CDB_LatLng(0, 0),
Array['total_pop','male_pop']::text[]
)) a
)
SELECT non_null = 0 as test_obsGetCensusWithNullIsland
FROM result;
--
-- names | vals