From 4c434f5448b9b658b1679d1ce05fa42e8119419a Mon Sep 17 00:00:00 2001 From: John Krauss Date: Fri, 22 Jul 2016 18:56:27 +0000 Subject: [PATCH] tests doublechecking NULL default handled correctly, and that area normalization for polygon is per square kilometer --- .../41_observatory_augmentation_test.out | 12 +++++++ .../sql/41_observatory_augmentation_test.sql | 32 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/pg/test/expected/41_observatory_augmentation_test.out b/src/pg/test/expected/41_observatory_augmentation_test.out index 2136326..b2efbf8 100644 --- a/src/pg/test/expected/41_observatory_augmentation_test.out +++ b/src/pg/test/expected/41_observatory_augmentation_test.out @@ -42,9 +42,21 @@ t obs_getmeasure_total_pop_point_test t (1 row) +obs_getmeasure_total_pop_point_null_normalization_test +t +(1 row) +obs_getmeasure_total_pop_point_area_test +t +(1 row) obs_getmeasure_total_pop_polygon_test t (1 row) +obs_getmeasure_total_pop_polygon_null_normalization_test +t +(1 row) +obs_getmeasure_total_pop_polygon_area_test +t +(1 row) obs_getmeasure_total_male_point_denominator t (1 row) diff --git a/src/pg/test/sql/41_observatory_augmentation_test.sql b/src/pg/test/sql/41_observatory_augmentation_test.sql index 0a6808e..e024317 100644 --- a/src/pg/test/sql/41_observatory_augmentation_test.sql +++ b/src/pg/test/sql/41_observatory_augmentation_test.sql @@ -148,6 +148,22 @@ SELECT abs(OBS_GetMeasure_total_pop_point - 10923.093200390833950) / 10923.09320 'us.census.acs.B01003001' ) As t(OBS_GetMeasure_total_pop_point); +-- Point-based OBS_GetMeasure, default normalization by NULL (area) +-- is result within 0.1% of expected +SELECT abs(OBS_GetMeasure_total_pop_point_null_normalization - 10923.093200390833950) / 10923.093200390833950 < 0.001 As OBS_GetMeasure_total_pop_point_null_normalization_test FROM + cdb_observatory.OBS_GetMeasure( + cdb_observatory._TestPoint(), + 'us.census.acs.B01003001', NULL +) As t(OBS_GetMeasure_total_pop_point_null_normalization); + +-- Point-based OBS_GetMeasure, explicit area normalization area +-- is result within 0.1% of expected +SELECT abs(OBS_GetMeasure_total_pop_point_area - 10923.093200390833950) / 10923.093200390833950 < 0.001 As OBS_GetMeasure_total_pop_point_area_test FROM + cdb_observatory.OBS_GetMeasure( + cdb_observatory._TestPoint(), + 'us.census.acs.B01003001', 'area' +) As t(OBS_GetMeasure_total_pop_point_area); + -- Poly-based OBS_GetMeasure, default normalization (none) -- is result within 0.1% of expected SELECT abs(OBS_GetMeasure_total_pop_polygon - 12327.3133495107) / 12327.3133495107 < 0.001 As OBS_GetMeasure_total_pop_polygon_test FROM @@ -156,6 +172,22 @@ SELECT abs(OBS_GetMeasure_total_pop_polygon - 12327.3133495107) / 12327.31334951 'us.census.acs.B01003001' ) As t(OBS_GetMeasure_total_pop_polygon); +-- Poly-based OBS_GetMeasure, default normalization by NULL (none) +-- is result within 0.1% of expected +SELECT abs(OBS_GetMeasure_total_pop_polygon_null_normalization - 12327.3133495107) / 12327.3133495107 < 0.001 As OBS_GetMeasure_total_pop_polygon_null_normalization_test FROM + cdb_observatory.OBS_GetMeasure( + cdb_observatory._TestArea(), + 'us.census.acs.B01003001', NULL +) As t(OBS_GetMeasure_total_pop_polygon_null_normalization); + +-- Poly-based OBS_GetMeasure, explicit area normalization +-- is result within 0.1% of expected +SELECT abs(OBS_GetMeasure_total_pop_polygon_area - 15787.4325563538) / 15787.4325563538 < 0.001 As OBS_GetMeasure_total_pop_polygon_area_test FROM + cdb_observatory.OBS_GetMeasure( + cdb_observatory._TestArea(), + 'us.census.acs.B01003001', 'area' +) As t(OBS_GetMeasure_total_pop_polygon_area); + -- Point-based OBS_GetMeasure with denominator normalization SELECT (abs(cdb_observatory.OBS_GetMeasure( cdb_observatory._TestPoint(),