Merge pull request #170 from CartoDB/handle-bad-geoms

Handle bad geoms
This commit is contained in:
john krauss 2016-07-25 09:15:09 -04:00 committed by GitHub
commit 360adc47df
4 changed files with 19 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -361,6 +361,7 @@ DECLARE
sql TEXT;
numer_name TEXT;
BEGIN
geom := ST_SnapToGrid(geom, 0.000001);
EXECUTE
$query$
@ -383,6 +384,7 @@ BEGIN
geom_type := 'point';
ELSIF ST_GeometryType(geom) IN ('ST_Polygon', 'ST_MultiPolygon') THEN
geom_type := 'polygon';
geom := ST_Buffer(geom, 0.000001);
ELSE
RAISE EXCEPTION 'Invalid geometry type (%), can only handle ''ST_Point'', ''ST_Polygon'', and ''ST_MultiPolygon''',
ST_GeometryType(geom);

View File

@ -63,6 +63,9 @@ t
obs_getmeasure_total_male_poly_denominator
t
(1 row)
obs_getmeasure_bad_geometry
t
(1 row)
obs_getcategory_point
t
(1 row)

View File

@ -198,6 +198,11 @@ SELECT abs(cdb_observatory.OBS_GetMeasure(
cdb_observatory._TestArea(),
'us.census.acs.B01001002', 'denominator') - 0.49026340444793965457) / 0.49026340444793965457 < 0.001 As OBS_GetMeasure_total_male_poly_denominator;
-- Poly-based OBS_GetMeasure with one very bad geom
SELECT abs(cdb_observatory.OBS_GetMeasure(
cdb_observatory._ProblemTestArea(),
'us.census.acs.B01003001') - 96230.2929825897) / 96230.2929825897 < 0.001 As OBS_GetMeasure_bad_geometry;
-- Point-based OBS_GetCategory
SELECT cdb_observatory.OBS_GetCategory(
cdb_observatory._TestPoint(), 'us.census.spielman_singleton_segments.X10') = 'Wealthy, urban without Kids' As OBS_GetCategory_point;