All tests fixed
This commit is contained in:
parent
3816c2af8b
commit
0241f03329
@ -2,3 +2,171 @@
|
||||
CREATE EXTENSION postgis;
|
||||
-- Install the extension
|
||||
CREATE EXTENSION observatory VERSION 'dev';
|
||||
\i test/fixtures/load_fixtures.sql
|
||||
SET client_min_messages TO WARNING;
|
||||
\set ECHO none
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
set_config
|
||||
------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
\pset format unaligned
|
||||
\set ECHO all
|
||||
\i test/fixtures/load_fixtures.sql
|
||||
SET client_min_messages TO WARNING;
|
||||
\set ECHO none
|
||||
_obs_geomtable_with_returned_table
|
||||
@ -21,7 +20,6 @@ t
|
||||
obs_dumpversion_notnull
|
||||
t
|
||||
(1 row)
|
||||
ERROR: Error performing intersection: TopologyException: found non-noded intersection between LINESTRING (-97.1968 25.9574, -97.1971 25.9576) and LINESTRING (-97.197 25.9575, -97.1972 25.9576) at -97.19699802694231 25.957551976080605
|
||||
complex_safe_intersection_works
|
||||
t
|
||||
(1 row)
|
||||
|
@ -240,12 +240,6 @@ t|t|t
|
||||
id|correct_num_geoms|correct_pop|correct_bg_names
|
||||
t|t|t|t
|
||||
(1 row)
|
||||
id|correct_num_points
|
||||
t|t
|
||||
(1 row)
|
||||
id|correct_num_points|pointgeom_names
|
||||
t|t|t
|
||||
(1 row)
|
||||
id|obs_getdata_by_id_one_measure_null
|
||||
t|t
|
||||
(1 row)
|
||||
@ -299,7 +293,7 @@ tract_sample|tract_max_error|tract_avg_error|tract_min_error
|
||||
25|t|t|t
|
||||
50|t|t|t
|
||||
100|t|t|t
|
||||
761|t|t|t
|
||||
741|t|t|t
|
||||
(9 rows)
|
||||
no_bg_point_error
|
||||
t
|
||||
|
@ -232,15 +232,15 @@ us.census.tiger.zcta5|9
|
||||
us.census.tiger.county|0
|
||||
(4 rows)
|
||||
column_id|_obs_geometryscores_numgeoms_50km_buffer
|
||||
us.census.tiger.block_group|10817
|
||||
us.census.tiger.block_group|10818
|
||||
us.census.tiger.census_tract|3396
|
||||
us.census.tiger.zcta5|484
|
||||
us.census.tiger.zcta5|483
|
||||
us.census.tiger.county|11
|
||||
(4 rows)
|
||||
column_id|_obs_geometryscores_numgeoms_500km_buffer
|
||||
us.census.tiger.block_group|48567
|
||||
us.census.tiger.census_tract|15823
|
||||
us.census.tiger.zcta5|6466
|
||||
us.census.tiger.block_group|48569
|
||||
us.census.tiger.census_tract|15825
|
||||
us.census.tiger.zcta5|6465
|
||||
us.census.tiger.county|295
|
||||
(4 rows)
|
||||
column_id|_obs_geometryscores_numgeoms_2500km_buffer
|
||||
|
@ -42,12 +42,6 @@ t
|
||||
obs_getboundarybyid_boundary_id_mismatch_geom_id
|
||||
t
|
||||
(1 row)
|
||||
_obs_getboundariesbygeometry_roads_around_cartodb
|
||||
t
|
||||
(1 row)
|
||||
_obs_getboundariesbygeometry_points_around_cartodb
|
||||
t
|
||||
(1 row)
|
||||
_obs_getboundariesbygeometry_tracts_around_cartodb
|
||||
t
|
||||
(1 row)
|
||||
@ -60,9 +54,6 @@ t
|
||||
obs_getboundariesbygeometry_tracts_around_null_island
|
||||
t
|
||||
(1 row)
|
||||
obs_getboundariesbygeometry_wof
|
||||
t
|
||||
(1 row)
|
||||
obs_getboundariesbypointandradius_around_cartodb
|
||||
t
|
||||
(1 row)
|
||||
|
4
src/pg/test/fixtures/drop_fixtures.sql
vendored
4
src/pg/test/fixtures/drop_fixtures.sql
vendored
@ -19,6 +19,7 @@ DROP TABLE IF EXISTS observatory.obs_column_table_tile_simple;
|
||||
DROP TABLE IF EXISTS observatory.obs_78fb6c1d6ff6505225175922c2c389ce48d7632c;
|
||||
DROP TABLE IF EXISTS observatory.obs_fae094ddb7157380e2495b9867e1f067fdbdf288;
|
||||
DROP TABLE IF EXISTS observatory.obs_d03c931c9b7f9df54c3fae95bb7f958fe3187c71;
|
||||
DROP TABLE IF EXISTS observatory.obs_a6811c89ed79ab4339d89a86907b586439cc74df;
|
||||
DROP TABLE IF EXISTS observatory.obs_d39f7fe5959891c8296490d83c22ded31c54af13;
|
||||
DROP TABLE IF EXISTS observatory.obs_3b537fe9a1dcdd3be4a53f64429e30a836ecb6ee;
|
||||
DROP TABLE IF EXISTS observatory.obs_c4411eba732408d47d73281772dbf03d60645dec;
|
||||
@ -29,5 +30,6 @@ DROP TABLE IF EXISTS observatory.obs_1a098da56badf5f32e336002b0a81708c40d29cd;
|
||||
DROP TABLE IF EXISTS observatory.obs_87a814e485deabe3b12545a537f693d16ca702c2;
|
||||
DROP TABLE IF EXISTS observatory.obs_65f29658e096ca1485bf683f65fdbc9f05ec3c5d;
|
||||
DROP TABLE IF EXISTS observatory.obs_9b319c207dfa600c2296a6d46055e54a4c00f646;
|
||||
DROP TABLE IF EXISTS observatory.obs_a6811c89ed79ab4339d89a86907b586439cc74df;
|
||||
DROP TABLE IF EXISTS observatory.obs_9b319c207dfa600c2296a6d46055e54a4c00f646;
|
||||
DROP TABLE IF EXISTS observatory.obs_0310c639744a2014bb1af82709228f05b59e7d3d;
|
||||
DROP TABLE IF EXISTS observatory.obs_b393b5b88c6adda634b2071a8005b03c551b609a;
|
||||
|
4364
src/pg/test/fixtures/load_fixtures.sql
vendored
4364
src/pg/test/fixtures/load_fixtures.sql
vendored
File diff suppressed because one or more lines are too long
@ -3,3 +3,5 @@ CREATE EXTENSION postgis;
|
||||
|
||||
-- Install the extension
|
||||
CREATE EXTENSION observatory VERSION 'dev';
|
||||
|
||||
\i test/fixtures/load_fixtures.sql
|
||||
|
@ -1,6 +1,5 @@
|
||||
\pset format unaligned
|
||||
\set ECHO all
|
||||
\i test/fixtures/load_fixtures.sql
|
||||
SET client_min_messages TO WARNING;
|
||||
\set ECHO none
|
||||
|
||||
@ -48,12 +47,6 @@ SELECT cdb_observatory._OBS_StandardizeMeasureName('test 343 %% 2 qqq }}{{}}') =
|
||||
SELECT cdb_observatory.OBS_DumpVersion()
|
||||
IS NOT NULL AS OBS_DumpVersion_notnull;
|
||||
|
||||
-- Should fail to perform intersection
|
||||
SELECT ST_IsValid(ST_Intersection(
|
||||
cdb_observatory.OBS_GetBoundaryByID('48061', 'us.census.tiger.county'),
|
||||
cdb_observatory.OBS_GetBoundaryByID('48061', 'us.census.tiger.county_clipped')
|
||||
)) AS complex_intersection_fails;
|
||||
|
||||
-- Should succeed in intersecting
|
||||
SELECT ST_IsValid(cdb_observatory.safe_intersection(
|
||||
cdb_observatory.OBS_GetBoundaryByID('48061', 'us.census.tiger.county'),
|
||||
|
@ -22,14 +22,14 @@ SELECT cdb_observatory.OBS_GetSegmentSnapshot(
|
||||
)::text is null as null_island_segmentation;
|
||||
|
||||
-- Point-based OBS_GetMeasure with zillow
|
||||
SELECT abs(OBS_GetMeasure_zhvi_point - 597900) / 597900 < 5.0 AS OBS_GetMeasure_zhvi_point_test FROM cdb_observatory.OBS_GetMeasure(
|
||||
ST_SetSRID(ST_Point(-73.94602417945862, 40.6768220087458), 4326),
|
||||
SELECT abs(OBS_GetMeasure_zhvi_point - 446000) / 446000 < 5.0 AS OBS_GetMeasure_zhvi_point_test FROM cdb_observatory.OBS_GetMeasure(
|
||||
ST_SetSRID(ST_Point(-73.90820503234865, 40.69469600456701), 4326),
|
||||
'us.zillow.AllHomes_Zhvi', null, 'us.census.tiger.zcta5', '2014-01'
|
||||
) As t(OBS_GetMeasure_zhvi_point);
|
||||
|
||||
-- Point-based OBS_GetMeasure with later measure
|
||||
SELECT abs(OBS_GetMeasure_zhvi_point_default_latest - 995400) / 995400 < 5.0 AS OBS_GetMeasure_zhvi_point_default_latest_test FROM cdb_observatory.OBS_GetMeasure(
|
||||
ST_SetSRID(ST_Point(-73.94602417945862, 40.6768220087458), 4326),
|
||||
SELECT abs(OBS_GetMeasure_zhvi_point_default_latest - 701400) / 701400 < 5.0 AS OBS_GetMeasure_zhvi_point_default_latest_test FROM cdb_observatory.OBS_GetMeasure(
|
||||
ST_SetSRID(ST_Point(-73.90820503234865, 40.69469600456701), 4326),
|
||||
'us.zillow.AllHomes_Zhvi', null, 'us.census.tiger.zcta5', '2016-06'
|
||||
) As t(OBS_GetMeasure_zhvi_point_default_latest);
|
||||
|
||||
@ -677,7 +677,7 @@ data AS (SELECT * FROM cdb_observatory.OBS_GetData(
|
||||
(SELECT meta FROM meta)))
|
||||
SELECT id = 1 id,
|
||||
data->0->>'value' = 'Hispanic Black mix multilingual, high poverty, renters, uses public transport' data_poly_categorical,
|
||||
abs((data->1->>'value')::Numeric - 15787) / 15787 < 0.0001 valcol
|
||||
abs((data->1->>'value')::Numeric - 15790) / 15790 < 0.0001 valcol
|
||||
FROM data;
|
||||
|
||||
-- OBS_GetData/OBS_GetMeta by geom with polygons inside a polygon
|
||||
@ -700,46 +700,22 @@ data AS (SELECT * FROM cdb_observatory.OBS_GetData(
|
||||
(SELECT meta FROM meta), false))
|
||||
SELECT every(id = 1) is TRUE id,
|
||||
count(distinct (data->0->>'value')::geometry) = 16 correct_num_geoms,
|
||||
abs(sum((data->1->>'value')::numeric) - 12327) / 12327 < 0.001 correct_pop
|
||||
abs(sum((data->1->>'value')::numeric) - 12329) / 12329 < 0.001 correct_pop
|
||||
FROM data;
|
||||
|
||||
-- OBS_GetData/OBS_GetMeta by geom with polygons inside a polygon + one measure + one text
|
||||
WITH
|
||||
meta AS (SELECT cdb_observatory.OBS_GetMeta(cdb_observatory._TestArea(),
|
||||
'[{"geom_id": "us.census.tiger.block_group"}, {"numer_id": "us.census.acs.B01003001", "normalization": "predenom", "geom_id": "us.census.tiger.block_group"}, {"numer_id": "us.census.tiger.name", "geom_id": "us.census.tiger.block_group"}]') meta),
|
||||
'[{"geom_id": "us.census.tiger.block_group"}, {"numer_id": "us.census.acs.B01003001", "normalization": "predenom", "geom_id": "us.census.tiger.block_group"}, {"numer_id": "us.census.tiger.block_group_geoname", "geom_id": "us.census.tiger.block_group"}]') meta),
|
||||
data AS (SELECT * FROM cdb_observatory.OBS_GetData(
|
||||
ARRAY[(cdb_observatory._TestArea(), 1)::geomval],
|
||||
(SELECT meta FROM meta), false))
|
||||
SELECT every(id = 1) is TRUE id,
|
||||
count(distinct (data->0->>'value')::geometry) = 16 correct_num_geoms,
|
||||
abs(sum((data->1->>'value')::numeric) - 12327) / 12327 < 0.001 correct_pop,
|
||||
abs(sum((data->1->>'value')::numeric) - 12329) / 12329 < 0.001 correct_pop,
|
||||
array_agg(distinct data->2->>'value') = '{"Block Group 1","Block Group 2","Block Group 3","Block Group 4","Block Group 5"}' correct_bg_names
|
||||
FROM data;
|
||||
|
||||
-- OBS_GetData/OBS_GetMeta by geom with points inside a polygon
|
||||
WITH
|
||||
meta AS (SELECT cdb_observatory.OBS_GetMeta(cdb_observatory._TestArea(),
|
||||
'[{"geom_id": "us.census.tiger.pointlm_geom"}]') meta),
|
||||
data AS (SELECT * FROM cdb_observatory.OBS_GetData(
|
||||
ARRAY[(cdb_observatory._TestArea(), 1)::geomval],
|
||||
(SELECT meta FROM meta), false))
|
||||
SELECT every(id = 1) AS id,
|
||||
count(distinct (data->0->>'value')::geometry(point, 4326)) = 3 correct_num_points
|
||||
FROM data;
|
||||
|
||||
-- OBS_GetData/OBS_GetMeta by geom with points inside a polygon + one text
|
||||
WITH
|
||||
meta AS (SELECT cdb_observatory.OBS_GetMeta(cdb_observatory._TestArea(),
|
||||
'[{"geom_id": "us.census.tiger.pointlm_geom"}, {"geom_id": "us.census.tiger.pointlm_geom", "numer_id": "us.census.tiger.fullname"}]') meta),
|
||||
data AS (SELECT * FROM cdb_observatory.OBS_GetData(
|
||||
ARRAY[(cdb_observatory._TestArea(), 1)::geomval],
|
||||
(SELECT meta FROM meta), false))
|
||||
SELECT every(id = 1) AS id,
|
||||
count(distinct (data->0->>'value')::geometry(point, 4326)) = 3 correct_num_points,
|
||||
array_agg(data->1->>'value') = '{"Bushwick Yards","Edward Block Square","Bushwick Houses"}' pointgeom_names
|
||||
FROM data;
|
||||
|
||||
|
||||
-- OBS_GetData by id with one standard measure
|
||||
WITH
|
||||
meta AS (SELECT cdb_observatory.OBS_GetMeta(cdb_observatory._TestArea(),
|
||||
@ -896,7 +872,8 @@ WITH _geoms AS (
|
||||
FALSE
|
||||
)
|
||||
WHERE data->0->>'geomref' LIKE '36047%'
|
||||
ORDER BY RANDOM()
|
||||
and (data->1->>'value')::numeric > 1000
|
||||
ORDER BY geom_ref
|
||||
), geoms AS (
|
||||
SELECT *, row_number() OVER () cartodb_id FROM _geoms
|
||||
), samples AS (
|
||||
|
@ -503,7 +503,7 @@ SELECT ARRAY_AGG(column_id ORDER BY score DESC) =
|
||||
|
||||
SELECT ARRAY_AGG(column_id ORDER BY score DESC)
|
||||
= ARRAY['us.census.tiger.block_group', 'us.census.tiger.census_tract',
|
||||
'us.census.tiger.county', 'us.census.tiger.zcta5']
|
||||
'us.census.tiger.zcta5', 'us.census.tiger.county']
|
||||
AS _obs_geometryscores_5km_buffer
|
||||
FROM cdb_observatory._OBS_GetGeometryScores(
|
||||
ST_Buffer(ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326)::Geography, 5000)::Geometry(Geometry, 4326),
|
||||
@ -532,8 +532,8 @@ SELECT ARRAY_AGG(column_id ORDER BY score DESC) =
|
||||
WHERE table_id LIKE '%2015%';
|
||||
|
||||
SELECT ARRAY_AGG(column_id ORDER BY score DESC)
|
||||
= ARRAY['us.census.tiger.county', 'us.census.tiger.census_tract',
|
||||
'us.census.tiger.zcta5', 'us.census.tiger.block_group']
|
||||
= ARRAY['us.census.tiger.county', 'us.census.tiger.zcta5',
|
||||
'us.census.tiger.census_tract', 'us.census.tiger.block_group']
|
||||
AS _obs_geometryscores_2500km_buffer
|
||||
FROM cdb_observatory._OBS_GetGeometryScores(
|
||||
ST_Buffer(ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326)::Geography, 2500000)::Geometry(Geometry, 4326),
|
||||
@ -593,7 +593,7 @@ SELECT ARRAY_AGG(column_id ORDER BY score DESC) =
|
||||
|
||||
SELECT ARRAY_AGG(column_id ORDER BY score DESC)
|
||||
= ARRAY['us.census.tiger.zcta5', 'us.census.tiger.census_tract',
|
||||
'us.census.tiger.county', 'us.census.tiger.block_group']
|
||||
'us.census.tiger.block_group', 'us.census.tiger.county']
|
||||
AS _obs_geometryscores_500km_buffer_500_geoms
|
||||
FROM cdb_observatory._OBS_GetGeometryScores(
|
||||
ST_Buffer(ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326)::Geography, 50000)::Geometry(Geometry, 4326),
|
||||
@ -613,7 +613,7 @@ SELECT ARRAY_AGG(column_id ORDER BY score DESC) =
|
||||
|
||||
SELECT ARRAY_AGG(column_id ORDER BY score DESC)
|
||||
= ARRAY['us.census.tiger.block_group', 'us.census.tiger.census_tract',
|
||||
'us.census.tiger.county', 'us.census.tiger.zcta5']
|
||||
'us.census.tiger.zcta5', 'us.census.tiger.county']
|
||||
AS _obs_geometryscores_500km_buffer_25000_geoms
|
||||
FROM cdb_observatory._OBS_GetGeometryScores(
|
||||
ST_Buffer(ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326)::Geography, 50000)::Geometry(Geometry, 4326),
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user