make bounds optional for dimensional queries, add all tests
This commit is contained in:
parent
50b745227b
commit
017b404264
@ -239,7 +239,7 @@ END
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableGeometries(
|
||||
bounds GEOMETRY,
|
||||
bounds GEOMETRY DEFAULT NULL,
|
||||
filter_tags TEXT[] DEFAULT NULL,
|
||||
numer_id TEXT DEFAULT NULL,
|
||||
denom_id TEXT DEFAULT NULL,
|
||||
@ -290,7 +290,7 @@ END
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableTimespans(
|
||||
bounds GEOMETRY,
|
||||
bounds GEOMETRY DEFAULT NULL,
|
||||
filter_tags TEXT[] DEFAULT NULL,
|
||||
numer_id TEXT DEFAULT NULL,
|
||||
denom_id TEXT DEFAULT NULL,
|
||||
@ -300,12 +300,12 @@ CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableTimespans(
|
||||
timespan_name TEXT,
|
||||
timespan_description TEXT,
|
||||
timespan_weight NUMERIC,
|
||||
timespan_aggregate TEXT,
|
||||
timespan_license TEXT,
|
||||
timespan_source TEXT,
|
||||
valid_numer BOOLEAN,
|
||||
valid_denom BOOLEAN,
|
||||
valid_geom BOOLEAN,
|
||||
stats JSONB -- information about # of geoms, avg geom size, etc.
|
||||
valid_geom BOOLEAN
|
||||
) AS $$
|
||||
DECLARE
|
||||
geom_clause TEXT;
|
||||
@ -331,8 +331,7 @@ BEGIN
|
||||
NULL::TEXT source,
|
||||
$1 = ANY(numers) valid_numer,
|
||||
$2 = ANY(denoms) valid_denom,
|
||||
$3 = ANY(geoms) valid_geom_id,
|
||||
NULL::JSONB stats
|
||||
$3 = ANY(geoms) valid_geom_id
|
||||
FROM observatory.obs_meta_timespan
|
||||
WHERE %s (timespan_tags ?& $4 OR CARDINALITY($4) = 0)
|
||||
$string$, geom_clause)
|
||||
|
@ -12,40 +12,136 @@ t
|
||||
_obs_getavailableboundariesexist
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_usa_pop_in_all
|
||||
_obs_getavailablenumerators_usa_pop_in_all
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_usa_pop_in_nyc_point
|
||||
_obs_getavailablenumerators_usa_pop_in_nyc_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_usa_pop_in_usa_extents
|
||||
_obs_getavailablenumerators_usa_pop_in_usa_extents
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_no_usa_pop_not_in_zero_point
|
||||
_obs_getavailablenumerators_no_usa_pop_not_in_zero_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_usa_pop_in_age_gender_subsection
|
||||
_obs_getavailablenumerators_usa_pop_in_age_gender_subsection
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_no_pop_in_income_subsection
|
||||
_obs_getavailablenumerators_no_pop_in_income_subsection
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_male_pop_denominated_by_total_pop
|
||||
_obs_getavailablenumerators_male_pop_denom_by_total_pop
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_no_income_denominated_by_total_pop
|
||||
_obs_getavailablenumerators_no_income_denom_by_total_pop
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_zillow_at_zcta5
|
||||
_obs_getavailablenumerators_zillow_at_zcta5
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_no_zillow_at_block_group
|
||||
_obs_getavailablenumerators_no_zillow_at_block_group
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_total_pop_2010_2014
|
||||
_obs_getavailablenumerators_total_pop_2010_2014
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavilablenumerators_no_total_pop_1996
|
||||
_obs_getavailablenumerators_no_total_pop_1996
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_usa_pop_in_all
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_usa_pop_in_nyc_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_usa_pop_in_usa_extents
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_no_usa_pop_not_in_zero_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_usa_pop_in_age_gender_subsection
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_no_pop_in_income_subsection
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_male_pop_denom_by_total_pop
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_no_income_denom_by_total_pop
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_at_zcta5
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_none_spanish_geom
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_total_pop_2010_2014
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabledenominators_no_total_pop_1996
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_usa_bg_in_all
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_usa_bg_in_nyc_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_usa_bg_in_usa_extents
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_no_usa_bg_not_in_zero_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_usa_bg_in_boundary_subsection
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_no_bg_in_uk_section
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_total_pop_in_usa_bg
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_foobarbaz_not_in_usa_bg
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_total_pop_denom_in_usa_bg
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_foobarbaz_denom_not_in_usa_bg
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_bg_2014
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_bg_not_1996
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabletimespans_2010_2014_in_all
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabletimespans_2010_2014_in_nyc_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabletimespans_2010_2014_in_usa_extents
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabletimespans_no_usa_bg_not_in_zero_point
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabletimespans_total_pop_in_2010_2014
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailabletimespans_foobarbaz_not_in_2010_2014
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_total_pop_denom_in_2010_2014
|
||||
t
|
||||
(1 row)
|
||||
_obs_getavailablegeometries_foobarbaz_denom_not_in_2010_2014
|
||||
t
|
||||
(1 row)
|
||||
_total_pop_in_legacy_builder_metadata
|
||||
|
231
src/pg/test/fixtures/load_fixtures.sql
vendored
231
src/pg/test/fixtures/load_fixtures.sql
vendored
File diff suppressed because one or more lines are too long
@ -40,13 +40,13 @@ FROM cdb_observatory.OBS_GetAvailableBoundaries(
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators())
|
||||
AS _obs_getavilablenumerators_usa_pop_in_all;
|
||||
AS _obs_getavailablenumerators_usa_pop_in_all;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavilablenumerators_usa_pop_in_nyc_point;
|
||||
)) AS _obs_getavailablenumerators_usa_pop_in_nyc_point;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
@ -55,114 +55,296 @@ FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
-47.4609375, 72.0739114882038
|
||||
), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavilablenumerators_usa_pop_in_usa_extents;
|
||||
)) AS _obs_getavailablenumerators_usa_pop_in_usa_extents;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(0, 0), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavilablenumerators_no_usa_pop_not_in_zero_point;
|
||||
)) AS _obs_getavailablenumerators_no_usa_pop_not_in_zero_point;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['subsection/tags.age_gender']
|
||||
))
|
||||
AS _obs_getavilablenumerators_usa_pop_in_age_gender_subsection;
|
||||
AS _obs_getavailablenumerators_usa_pop_in_age_gender_subsection;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['subsection/tags.income']
|
||||
))
|
||||
AS _obs_getavilablenumerators_no_pop_in_income_subsection;
|
||||
AS _obs_getavailablenumerators_no_pop_in_income_subsection;
|
||||
|
||||
SELECT 'us.census.acs.B01001002' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B01003001'
|
||||
) WHERE valid_denom = True)
|
||||
AS _obs_getavilablenumerators_male_pop_denominated_by_total_pop;
|
||||
AS _obs_getavailablenumerators_male_pop_denom_by_total_pop;
|
||||
|
||||
SELECT 'us.census.acs.B19013001' NOT IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B01003001'
|
||||
) WHERE valid_denom = True)
|
||||
AS _obs_getavilablenumerators_no_income_denominated_by_total_pop;
|
||||
AS _obs_getavailablenumerators_no_income_denom_by_total_pop;
|
||||
|
||||
SELECT 'us.zillow.AllHomes_Zhvi' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'us.census.tiger.zcta5'
|
||||
) WHERE valid_geom = True)
|
||||
AS _obs_getavilablenumerators_zillow_at_zcta5;
|
||||
AS _obs_getavailablenumerators_zillow_at_zcta5;
|
||||
|
||||
SELECT 'us.zillow.AllHomes_Zhvi' NOT IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'us.census.tiger.block_group'
|
||||
) WHERE valid_geom = True)
|
||||
AS _obs_getavilablenumerators_no_zillow_at_block_group;
|
||||
AS _obs_getavailablenumerators_no_zillow_at_block_group;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, '2010 - 2014'
|
||||
) WHERE valid_timespan = True)
|
||||
AS _obs_getavilablenumerators_total_pop_2010_2014;
|
||||
AS _obs_getavailablenumerators_total_pop_2010_2014;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT numer_id
|
||||
FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, '1996'
|
||||
) WHERE valid_timespan = True)
|
||||
AS _obs_getavilablenumerators_no_total_pop_1996;
|
||||
|
||||
/*
|
||||
SELECT * FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['unit/tags.money'], '', '', ''
|
||||
);
|
||||
|
||||
SELECT * FROM cdb_observatory.OBS_GetAvailableNumerators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['unit/tags.money', 'subsection/tags.housing'], '', '', ''
|
||||
);
|
||||
*/
|
||||
AS _obs_getavailablenumerators_no_total_pop_1996;
|
||||
|
||||
--
|
||||
-- OBS_GetAvailableDenominators tests
|
||||
--
|
||||
|
||||
/*
|
||||
SELECT * FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators())
|
||||
AS _obs_getavailabledenominators_usa_pop_in_all;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B03002006', 'us.census.tiger.census_tract', ''
|
||||
) where valid_numer IS true and valid_geom IS true;
|
||||
*/
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailabledenominators_usa_pop_in_nyc_point;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakeEnvelope(
|
||||
-169.8046875, 21.289374355860424,
|
||||
-47.4609375, 72.0739114882038
|
||||
), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailabledenominators_usa_pop_in_usa_extents;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(0, 0), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailabledenominators_no_usa_pop_not_in_zero_point;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['subsection/tags.age_gender']
|
||||
))
|
||||
AS _obs_getavailabledenominators_usa_pop_in_age_gender_subsection;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['subsection/tags.income']
|
||||
))
|
||||
AS _obs_getavailabledenominators_no_pop_in_income_subsection;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B01001002'
|
||||
) WHERE valid_numer = True)
|
||||
AS _obs_getavailabledenominators_male_pop_denom_by_total_pop;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B19013001'
|
||||
) WHERE valid_numer = True)
|
||||
AS _obs_getavailabledenominators_no_income_denom_by_total_pop;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'us.census.tiger.zcta5'
|
||||
) WHERE valid_geom = True)
|
||||
AS _obs_getavailabledenominators_at_zcta5;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'es.ine.the_geom'
|
||||
) WHERE valid_geom = True)
|
||||
AS _obs_getavailabledenominators_none_spanish_geom;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, '2010 - 2014'
|
||||
) WHERE valid_timespan = True)
|
||||
AS _obs_getavailabledenominators_total_pop_2010_2014;
|
||||
|
||||
SELECT 'us.census.acs.B01003001' NOT IN (SELECT denom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableDenominators(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, '1996'
|
||||
) WHERE valid_timespan = True)
|
||||
AS _obs_getavailabledenominators_no_total_pop_1996;
|
||||
|
||||
--
|
||||
-- OBS_GetAvailableGeometries tests
|
||||
--
|
||||
|
||||
/*
|
||||
SELECT * FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries())
|
||||
AS _obs_getavailablegeometries_usa_bg_in_all;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B03002006', 'us.census.acs.B01003001', ''
|
||||
) where valid_numer IS true and valid_denom IS true;
|
||||
*/
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailablegeometries_usa_bg_in_nyc_point;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakeEnvelope(
|
||||
-169.8046875, 21.289374355860424,
|
||||
-47.4609375, 72.0739114882038
|
||||
), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailablegeometries_usa_bg_in_usa_extents;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' NOT IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(0, 0), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailablegeometries_no_usa_bg_not_in_zero_point;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['subsection/tags.boundary']
|
||||
))
|
||||
AS _obs_getavailablegeometries_usa_bg_in_boundary_subsection;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' NOT IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
ARRAY['section/tags.uk']
|
||||
))
|
||||
AS _obs_getavailablegeometries_no_bg_in_uk_section;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B01003001'
|
||||
) WHERE valid_numer = True)
|
||||
AS _obs_getavailablegeometries_total_pop_in_usa_bg;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' NOT IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'foo.bar.baz'
|
||||
) WHERE valid_numer = True)
|
||||
AS _obs_getavailablegeometries_foobarbaz_not_in_usa_bg;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'us.census.acs.B01003001'
|
||||
) WHERE valid_denom = True)
|
||||
AS _obs_getavailablegeometries_total_pop_denom_in_usa_bg;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' NOT IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'foo.bar.baz'
|
||||
) WHERE valid_denom = True)
|
||||
AS _obs_getavailablegeometries_foobarbaz_denom_not_in_usa_bg;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, '2014'
|
||||
) WHERE valid_timespan = True)
|
||||
AS _obs_getavailablegeometries_bg_2014;
|
||||
|
||||
SELECT 'us.census.tiger.block_group' NOT IN (SELECT geom_id
|
||||
FROM cdb_observatory.OBS_GetAvailableGeometries(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, NULL, '1996'
|
||||
) WHERE valid_timespan = True)
|
||||
AS _obs_getavailablegeometries_bg_not_1996;
|
||||
|
||||
--
|
||||
-- OBS_GetAvailableTimespans tests
|
||||
--
|
||||
|
||||
/*
|
||||
SELECT * FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
SELECT '2010 - 2014' IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans())
|
||||
AS _obs_getavailabletimespans_2010_2014_in_all;
|
||||
|
||||
SELECT '2010 - 2014' IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B03002006', 'us.census.acs.B01003001', 'us.census.tiger.census_tract'
|
||||
) where valid_numer IS true and valid_denom IS true AND valid_geom IS true;
|
||||
*/
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailabletimespans_2010_2014_in_nyc_point;
|
||||
|
||||
SELECT '2010 - 2014' IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakeEnvelope(
|
||||
-169.8046875, 21.289374355860424,
|
||||
-47.4609375, 72.0739114882038
|
||||
), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailabletimespans_2010_2014_in_usa_extents;
|
||||
|
||||
SELECT '2010 - 2014' NOT IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakePoint(0, 0), 4326),
|
||||
NULL, NULL, NULL, NULL
|
||||
)) AS _obs_getavailabletimespans_no_usa_bg_not_in_zero_point;
|
||||
|
||||
SELECT '2010 - 2014' IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'us.census.acs.B01003001'
|
||||
) WHERE valid_numer = True)
|
||||
AS _obs_getavailabletimespans_total_pop_in_2010_2014;
|
||||
|
||||
SELECT '2010 - 2014' NOT IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, 'foo.bar.baz'
|
||||
) WHERE valid_numer = True)
|
||||
AS _obs_getavailabletimespans_foobarbaz_not_in_2010_2014;
|
||||
|
||||
SELECT '2010 - 2014' IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'us.census.acs.B01003001'
|
||||
) WHERE valid_denom = True)
|
||||
AS _obs_getavailablegeometries_total_pop_denom_in_2010_2014;
|
||||
|
||||
SELECT '2010 - 2014' NOT IN (SELECT timespan_id
|
||||
FROM cdb_observatory.OBS_GetAvailableTimespans(
|
||||
ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326),
|
||||
NULL, NULL, 'foo.bar.baz'
|
||||
) WHERE valid_denom = True)
|
||||
AS _obs_getavailablegeometries_foobarbaz_denom_not_in_2010_2014;
|
||||
|
||||
-- OBS_LegacyBuilderMetadata tests
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user