From 6fe467366a81cc294164cdf3dc5100dcd01c1617 Mon Sep 17 00:00:00 2001 From: abelvm Date: Thu, 18 Aug 2016 09:31:08 -0400 Subject: [PATCH 1/5] removed spurious segments --- src/pg/sql/09_voronoi.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pg/sql/09_voronoi.sql b/src/pg/sql/09_voronoi.sql index 20de189..eb5921b 100644 --- a/src/pg/sql/09_voronoi.sql +++ b/src/pg/sql/09_voronoi.sql @@ -25,7 +25,7 @@ BEGIN convexhull_1 as ( SELECT ST_ConvexHull(ST_Collect(geomin)) as g, - buffer * |/ st_area(ST_ConvexHull(ST_Collect(geomin))) as r + buffer * |/ (st_area(ST_ConvexHull(ST_Collect(geomin)))/PI()) as r ), clipper as( SELECT @@ -153,7 +153,8 @@ BEGIN INTO geomout FROM voro_set v, - clipper c; + clipper c + WHERE ST_GeometryType(v.g) = 'ST_Polygon'; RETURN geomout; END; $$ language plpgsql IMMUTABLE; From 4352d3ded7be486646af737a7de445a3311dd6de Mon Sep 17 00:00:00 2001 From: abelvm Date: Thu, 18 Aug 2016 09:36:15 -0400 Subject: [PATCH 2/5] removed spurious segments --- src/pg/test/expected/09_voronoi_test.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pg/test/expected/09_voronoi_test.out b/src/pg/test/expected/09_voronoi_test.out index 1ccc695..ac2d3b7 100644 --- a/src/pg/test/expected/09_voronoi_test.out +++ b/src/pg/test/expected/09_voronoi_test.out @@ -2,6 +2,6 @@ SET client_min_messages TO WARNING; \set ECHO none avg_area ---------------------- - 0.000200480682454162 + 0.000178661712160428 (1 row) From ce86c4c5b47feb3de2a95a631eee643e1903adc6 Mon Sep 17 00:00:00 2001 From: abelvm Date: Thu, 18 Aug 2016 10:12:15 -0400 Subject: [PATCH 3/5] removed spikes --- src/pg/sql/09_voronoi.sql | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pg/sql/09_voronoi.sql b/src/pg/sql/09_voronoi.sql index eb5921b..361525c 100644 --- a/src/pg/sql/09_voronoi.sql +++ b/src/pg/sql/09_voronoi.sql @@ -145,16 +145,26 @@ BEGIN SELECT (st_dump(v.g)).geom as g FROM voro_cells v + ), + clipped_voro as( + SELECT + ST_intersection(c.g, v.g) as g + FROM + voro_set v, + clipper c + WHERE + ST_GeometryType(v.g) = 'ST_Polygon' ) SELECT st_collect( - ST_Transform(ST_intersection(c.g, v.g), 4326) + ST_Transform( + ST_ConvexHull(g), + 4326 + ) ) INTO geomout FROM - voro_set v, - clipper c - WHERE ST_GeometryType(v.g) = 'ST_Polygon'; + clipped_voro; RETURN geomout; END; $$ language plpgsql IMMUTABLE; From 6fc460f6db5d830ea68c9034cff05c768461618c Mon Sep 17 00:00:00 2001 From: abelvm Date: Thu, 18 Aug 2016 10:16:26 -0400 Subject: [PATCH 4/5] removed spikes --- src/pg/test/expected/09_voronoi_test.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pg/test/expected/09_voronoi_test.out b/src/pg/test/expected/09_voronoi_test.out index ac2d3b7..58b9e50 100644 --- a/src/pg/test/expected/09_voronoi_test.out +++ b/src/pg/test/expected/09_voronoi_test.out @@ -2,6 +2,6 @@ SET client_min_messages TO WARNING; \set ECHO none avg_area ---------------------- - 0.000178661712160428 + 0.000178661700690617 (1 row) From 1061c854058a65032ee22bcbb22720005753823f Mon Sep 17 00:00:00 2001 From: abelvm Date: Thu, 18 Aug 2016 11:16:12 -0400 Subject: [PATCH 5/5] doc example fixed --- doc/09_voronoi.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/09_voronoi.md b/doc/09_voronoi.md index c3ec501..1a19103 100644 --- a/doc/09_voronoi.md +++ b/doc/09_voronoi.md @@ -27,9 +27,12 @@ PostGIS wil include this in future versions ([doc for dev branch](http://postgis ```sql WITH a AS ( SELECT - ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS geomin + ARRAY[ST_GeomFromText('POINT(2.1744 41.403)', 4326),ST_GeomFromText('POINT(2.1228 41.380)', 4326),ST_GeomFromText('POINT(2.1511 41.374)', 4326),ST_GeomFromText('POINT(2.1528 41.413)', 4326),ST_GeomFromText('POINT(2.165 41.391)', 4326),ST_GeomFromText('POINT(2.1498 41.371)', 4326),ST_GeomFromText('POINT(2.1533 41.368)', 4326),ST_GeomFromText('POINT(2.131386 41.41399)', 4326)] AS geomin ) SELECT - CDB_voronoi(geomin, 0.2, 1e-9) as result + st_transform( + (st_dump(CDB_voronoi(geomin, 0.2, 1e-9) + )).geom + , 3857) as the_geom_webmercator FROM a; ```