diff --git a/src/pg/test/expected/41_observatory_augmentation_test.out b/src/pg/test/expected/41_observatory_augmentation_test.out index 8ac2b1f..e561c75 100644 --- a/src/pg/test/expected/41_observatory_augmentation_test.out +++ b/src/pg/test/expected/41_observatory_augmentation_test.out @@ -31,9 +31,9 @@ Loading obs_11ee8b82c877c073438bc935a91d3dfccef875d1.sql fixture file... Done. Loading obs_d34555209878e8c4b37cf0b2b3d072ff129ec470.sql fixture file... Done. - obs_getdemographicsnapshot ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - (9516.27603138953,6152.51682996181,3363.75920142772,28.8,5301.51450207924,149.500408952343,230.000629157451,3835.26049120049,0,0,0,5681.01554018904,3323.50909132517,7107.01944096523,1040.75284693747,69.0001887472353,793.502170593206,327.750896549367,2742.7575027026,931.502548087676,66304,0.3494,28291,3662.76001933241,339.25092800724,120.750330307662,0,1764,35.3,339.25092800724,0,224.250613428515,6549.26791525841,327.750896549367,28.7500786446814,201.25055051277,621.001698725117,373.751022380858,1851.50506471748,1414.50386931832,1115.50305141364,615.251682996181,,57.5001572893627,0,212.750581970642,408.251116754475,0,155.250424681279,109.250298849789,92.0002516629803,63.250173018299,184.000503325961,621.001698725117,552.001509977882,327.750896549367,333.500912278304,126.500346036598,,) + total_pop | male_pop | female_pop | median_age | white_pop | black_pop | asian_pop | hispanic_pop | amerindian_pop | other_race_pop | two_or_more_races_pop | not_hispanic_pop | households | pop_25_years_over | high_school_diploma | less_one_year_college | one_year_more_college | associates_degree | bachelors_degree | masters_degree | median_income | gini_index | income_per_capita | housing_units | vacant_housing_units | vacant_housing_units_for_rent | vacant_housing_units_for_sale | median_rent | percent_income_spent_on_rent | owner_occupied_housing_units | million_dollar_housing_units | mortgaged_housing_units | commuters_16_over | commute_less_10_mins | commute_10_14_mins | commute_15_19_mins | commute_20_24_mins | commute_25_29_mins | commute_30_34_mins | commute_35_44_mins | commute_45_59_mins | commute_60_more_mins | aggregate_travel_time_to_work | income_less_10000 | income_10000_14999 | income_15000_19999 | income_20000_24999 | income_25000_29999 | income_30000_34999 | income_35000_39999 | income_40000_44999 | income_45000_49999 | income_50000_59999 | income_60000_74999 | income_75000_99999 | income_100000_124999 | income_125000_149999 | income_150000_199999 | income_200000_or_more | land_area +------------------+------------------+------------------+------------+------------------+------------------+------------------+------------------+----------------+----------------+-----------------------+------------------+------------------+-------------------+---------------------+-----------------------+-----------------------+-------------------+------------------+------------------+---------------+------------+-------------------+------------------+----------------------+-------------------------------+-------------------------------+-------------+------------------------------+------------------------------+------------------------------+-------------------------+-------------------+----------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+----------------------+-------------------------------+-------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+----------------------+----------------------+----------------------+-----------------------+----------- + 9516.27603138953 | 6152.51682996181 | 3363.75920142772 | 28.8 | 5301.51450207924 | 149.500408952343 | 230.000629157451 | 3835.26049120049 | 0 | 0 | 0 | 5681.01554018904 | 3323.50909132517 | 7107.01944096523 | 1040.75284693747 | 69.0001887472353 | 793.502170593206 | 327.750896549367 | 2742.7575027026 | 931.502548087676 | 66304 | 0.3494 | 28291 | 3662.76001933241 | 339.25092800724 | 120.750330307662 | 0 | 1764 | 35.3 | 339.25092800724 | 0 | 224.250613428515 | 6549.26791525841 | 327.750896549367 | 28.7500786446814 | 201.25055051277 | 621.001698725117 | 373.751022380858 | 1851.50506471748 | 1414.50386931832 | 1115.50305141364 | 615.251682996181 | | 57.5001572893627 | 0 | 212.750581970642 | 408.251116754475 | 0 | 155.250424681279 | 109.250298849789 | 92.0002516629803 | 63.250173018299 | 184.000503325961 | 621.001698725117 | 552.001509977882 | 327.750896549367 | 333.500912278304 | 126.500346036598 | | (1 row) dimension | dimension_value @@ -41,6 +41,16 @@ Done. {total_pop,male_pop} | {9516.27603138953,6152.51682996181} (1 row) + dimension | dimension_value +-----------------------+----------------- + {female_pop,male_pop} | {NULL,NULL} +(1 row) + + dimension | dimension_value +-----------------------+----------------- + {female_pop,male_pop} | {} +(1 row) + names | vals --------------+---------- {gini_index} | {0.3494} @@ -56,14 +66,14 @@ Done. {1570.72353789469} (1 row) - obs_getsegmentsnapshot --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ("Wealthy, urban without Kids",0.234783783783784,0.422405405405405,0.0987567567567568,0.0715,0.295310810810811,0.407189189189189,0.625608108108108,0.795202702702703,0.703797297297297,0.59227027027027,0.0180540540540541,0.993756756756757,0.728162162162162,0.995972972972973,0.929135135135135,0.625432432432432,0.0386081081081081,0.157121621621622,0.241878378378378,0.173783783783784,0.0380675675675676,0.0308108108108108,0.0486216216216216,0.479743243243243,0.297675675675676,0.190351351351351,0.802513513513514,0.757148648648649,0.255405405405405,0.196094594594595,0.816851351351351,0.252513513513514,0.560054054054054,0.777472972972973,0.336932432432432,0.655378378378378,0.141810810810811,0.362824324324324,0.463837837837838,0,0.939040540540541,0.419445945945946,0.0387972972972973,0) + segment_name | total_pop_quantile | male_pop_quantile | female_pop_quantile | median_age_quantile | white_pop_quantile | black_pop_quantile | asian_pop_quantile | hispanic_pop_quantile | not_us_citizen_pop_quantile | workers_16_and_over_quantile | commuters_by_car_truck_van_quantile | commuters_by_public_transportation_quantile | commuters_by_bus_quantile | commuters_by_subway_or_elevated_quantile | walked_to_work_quantile | worked_at_home_quantile | children_quantile | households_quantile | population_3_years_over_quantile | in_school_quantile | in_grades_1_to_4_quantile | in_grades_5_to_8_quantile | in_grades_9_to_12_quantile | in_undergrad_college_quantile | pop_25_years_over_quantile | high_school_diploma_quantile | bachelors_degree_quantile | masters_degree_quantile | pop_5_years_over_quantile | speak_only_english_at_home_quantile | speak_spanish_at_home_quantile | pop_determined_poverty_status_quantile | poverty_quantile | median_income_quantile | gini_index_quantile | income_per_capita_quantile | housing_units_quantile | vacant_housing_units_quantile | vacant_housing_units_for_rent_quantile | vacant_housing_units_for_sale_quantile | median_rent_quantile | percent_income_spent_on_rent_quantile | owner_occupied_housing_units_quantile | million_dollar_housing_units_quantile +-----------------------------+--------------------+-------------------+---------------------+---------------------+--------------------+--------------------+--------------------+-----------------------+-----------------------------+------------------------------+-------------------------------------+---------------------------------------------+---------------------------+------------------------------------------+-------------------------+-------------------------+--------------------+---------------------+----------------------------------+--------------------+---------------------------+---------------------------+----------------------------+-------------------------------+----------------------------+------------------------------+---------------------------+-------------------------+---------------------------+-------------------------------------+--------------------------------+----------------------------------------+-------------------+------------------------+---------------------+----------------------------+------------------------+-------------------------------+----------------------------------------+----------------------------------------+----------------------+---------------------------------------+---------------------------------------+--------------------------------------- + Wealthy, urban without Kids | 0.234783783783784 | 0.422405405405405 | 0.0987567567567568 | 0.0715 | 0.295310810810811 | 0.407189189189189 | 0.625608108108108 | 0.795202702702703 | 0.703797297297297 | 0.59227027027027 | 0.0180540540540541 | 0.993756756756757 | 0.728162162162162 | 0.995972972972973 | 0.929135135135135 | 0.625432432432432 | 0.0386081081081081 | 0.157121621621622 | 0.241878378378378 | 0.173783783783784 | 0.0380675675675676 | 0.0308108108108108 | 0.0486216216216216 | 0.479743243243243 | 0.297675675675676 | 0.190351351351351 | 0.802513513513514 | 0.757148648648649 | 0.255405405405405 | 0.196094594594595 | 0.816851351351351 | 0.252513513513514 | 0.560054054054054 | 0.777472972972973 | 0.336932432432432 | 0.655378378378378 | 0.141810810810811 | 0.362824324324324 | 0.463837837837838 | 0 | 0.939040540540541 | 0.419445945945946 | 0.0387972972972973 | 0 (1 row) - obs_getcategories ------------------------------------------------------------------------------------ - ("{X10,x10}","{""Wealthy, urban without Kids"",""Wealthy, urban without Kids""}") + names | categories +-----------+--------------------------------------------------------------- + {X10,x10} | {"Wealthy, urban without Kids","Wealthy, urban without Kids"} (1 row) Dropping obs_table.sql fixture table... diff --git a/src/pg/test/sql/41_observatory_augmentation_test.sql b/src/pg/test/sql/41_observatory_augmentation_test.sql index 8824224..77ad9fb 100644 --- a/src/pg/test/sql/41_observatory_augmentation_test.sql +++ b/src/pg/test/sql/41_observatory_augmentation_test.sql @@ -7,12 +7,12 @@ SELECT set_config( \i test/sql/load_fixtures.sql -- -SELECT +SELECT * FROM cdb_observatory.OBS_GetDemographicSnapshot( cdb_observatory._TestPoint(), '2009 - 2013', '"us.census.tiger".block_group' - ); + ) As snapshot; -- -- dimension | dimension_value @@ -27,6 +27,22 @@ FROM Array['total_pop','male_pop']::text[] ); +-- 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[] + ); +-- 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[] + ); + -- -- names | vals -- -----------|------- @@ -64,13 +80,13 @@ SELECT Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::OBS_ColumnData] ); -SELECT +SELECT * FROM cdb_observatory.OBS_GetSegmentSnapshot( _TestPoint(), '"us.census.tiger".census_tract' ); -SELECT +SELECT * FROM cdb_observatory.OBS_GetCategories( _TestPoint(), Array['"us.census.spielman_singleton_segments".X10'],