use simplification in obs_getdata for very complex geoms

This commit is contained in:
John Krauss 2017-01-18 21:44:02 +00:00
parent fc74529a04
commit 0e4a514753
2 changed files with 8 additions and 3 deletions

View File

@ -671,9 +671,14 @@ BEGIN
USING (SELECT ARRAY(SELECT json_array_elements_text(params))::json[]); USING (SELECT ARRAY(SELECT json_array_elements_text(params))::json[]);
RETURN QUERY EXECUTE format($query$ RETURN QUERY EXECUTE format($query$
WITH _geoms AS (SELECT WITH _raw_geoms AS (SELECT
(UNNEST($1)).val as id, (UNNEST($1)).val as id,
(UNNEST($1)).geom AS geom) (UNNEST($1)).geom AS geom),
_geoms AS (SELECT id,
CASE WHEN (ST_NPoints(geom) > 500)
THEN ST_CollectionExtract(ST_MakeValid(ST_SimplifyVW(geom, 0.0001)), 3)
ELSE geom END geom
FROM _raw_geoms)
SELECT _geoms.id::INT, Array_to_JSON(ARRAY[%s]::JSON[]) SELECT _geoms.id::INT, Array_to_JSON(ARRAY[%s]::JSON[])
FROM _geoms, %s FROM _geoms, %s
%s %s

View File

@ -343,7 +343,7 @@ WHERE obs_perftest_{complexity}.cartodb_id = data.id
if 'OBS_RECORD_TEST' in os.environ: if 'OBS_RECORD_TEST' in os.environ:
record({ record({
'geom_complexity': geom_complexity, 'geom_complexity': geom_complexity,
'api_method': 'OBS_GetMeasureMeta/OBS_GetMeasureData', 'api_method': 'OBS_GetData',
'normalization': normalization, 'normalization': normalization,
'boundary': boundary, 'boundary': boundary,
'geom': geom 'geom': geom