Merge pull request #114 from CartoDB/add-voronoi
[FIX] Voronoi spurious segments [09]
This commit is contained in:
commit
66a0c80aee
@ -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;
|
||||
```
|
||||
|
@ -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
|
||||
@ -145,15 +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;
|
||||
clipped_voro;
|
||||
RETURN geomout;
|
||||
END;
|
||||
$$ language plpgsql IMMUTABLE;
|
||||
|
@ -2,6 +2,6 @@ SET client_min_messages TO WARNING;
|
||||
\set ECHO none
|
||||
avg_area
|
||||
----------------------
|
||||
0.000200480682454162
|
||||
0.000178661700690617
|
||||
(1 row)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user