diff --git a/src/pg/test/expected/41_observatory_augmentation_test.out b/src/pg/test/expected/41_observatory_augmentation_test.out new file mode 100644 index 0000000..8ac2b1f --- /dev/null +++ b/src/pg/test/expected/41_observatory_augmentation_test.out @@ -0,0 +1,88 @@ +SELECT set_config( + 'search_path', + current_setting('search_path') || ',cdb_observatory,observatory', + false +) WHERE current_setting('search_path') !~ '(^|,)(cdb_observatory|observatory)(,|$)'; + set_config +------------------------------------------------------ + "$user", public, cartodb,cdb_observatory,observatory +(1 row) + +\i test/sql/load_fixtures.sql +SET client_min_messages TO WARNING; +\set ECHO none +Loading obs_table.sql fixture file... +Done. +Loading obs_column.sql fixture file... +Done. +Loading obs_column_table.sql fixture file... +Done. +Loading obs_column_to_column.sql fixture file... +Done. +Loading obs_85328201013baa14e8e8a4a57a01e6f6fbc5f9b1.sql fixture file... +Done. +Loading obs_3e7cc9cfd403b912c57b42d5f9195af9ce2f3cdb.sql fixture file... +Done. +Loading obs_ab038198aaab3f3cb055758638ee4de28ad70146.sql fixture file... +Done. +Loading obs_a92e1111ad3177676471d66bb8036e6d057f271b.sql fixture file... +Done. +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,,) +(1 row) + + dimension | dimension_value +----------------------+------------------------------------- + {total_pop,male_pop} | {9516.27603138953,6152.51682996181} +(1 row) + + names | vals +--------------+---------- + {gini_index} | {0.3494} +(1 row) + + obs_getpoints +-------------------- + {4809.33380072727} +(1 row) + + obs_getpolygons +-------------------- + {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) +(1 row) + + obs_getcategories +----------------------------------------------------------------------------------- + ("{X10,x10}","{""Wealthy, urban without Kids"",""Wealthy, urban without Kids""}") +(1 row) + +Dropping obs_table.sql fixture table... +Done. +Dropping obs_column.sql fixture table... +Done. +Dropping obs_column_table.sql fixture table... +Done. +Dropping obs_column_to_column.sql fixture table... +Done. +Dropping obs_85328201013baa14e8e8a4a57a01e6f6fbc5f9b1 fixture table... +Done. +Dropping obs_3e7cc9cfd403b912c57b42d5f9195af9ce2f3cdb fixture table... +Done. +Dropping obs_ab038198aaab3f3cb055758638ee4de28ad70146 fixture table... +Done. +Dropping obs_a92e1111ad3177676471d66bb8036e6d057f271b fixture table... +Done. +Dropping obs_11ee8b82c877c073438bc935a91d3dfccef875d1 fixture table... +Done. +Dropping obs_d34555209878e8c4b37cf0b2b3d072ff129ec470 fixture table... +Done. diff --git a/src/pg/test/sql/41_observatory_augmentation_test.sql b/src/pg/test/sql/41_observatory_augmentation_test.sql new file mode 100644 index 0000000..8824224 --- /dev/null +++ b/src/pg/test/sql/41_observatory_augmentation_test.sql @@ -0,0 +1,80 @@ +SELECT set_config( + 'search_path', + current_setting('search_path') || ',cdb_observatory,observatory', + false +) WHERE current_setting('search_path') !~ '(^|,)(cdb_observatory|observatory)(,|$)'; + +\i test/sql/load_fixtures.sql + +-- +SELECT + cdb_observatory.OBS_GetDemographicSnapshot( + cdb_observatory._TestPoint(), + '2009 - 2013', + '"us.census.tiger".block_group' + ); + +-- +-- dimension | dimension_value +-- ----------|---------------- +-- total_pop | 9516.27915900609 +-- male_pop | 6152.51885204623 + +SELECT * +FROM + cdb_observatory.OBS_GetCensus( + cdb_observatory._TestPoint(), + Array['total_pop','male_pop']::text[] + ); + +-- +-- names | vals +-- -----------|------- +-- gini_index | 0.3494 + +SELECT * FROM + cdb_observatory.OBS_Get( + cdb_observatory._TestPoint(), + Array['"us.census.acs".B19083001']::text[], + '2009 - 2013', + '"us.census.tiger".block_group' + ); + +-- OBS_GetPoints +-- obs_getpoints +-- -------------------- +-- {4809.33511352425} + +SELECT + 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] + ); + +-- OBS_GetPolygons +-- obs_getpolygons +-- -------------------- +-- {12996.8172420752} + +SELECT + OBS_GetPolygons( + _TestArea(), + 'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable + Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::OBS_ColumnData] +); + +SELECT + cdb_observatory.OBS_GetSegmentSnapshot( + _TestPoint(), + '"us.census.tiger".census_tract' +); + +SELECT + cdb_observatory.OBS_GetCategories( + _TestPoint(), + Array['"us.census.spielman_singleton_segments".X10'], + '"us.census.tiger".census_tract' +); + +\i test/sql/drop_fixtures.sql