From 94497cd79191eca656eafcd86fe0a79114ed8be9 Mon Sep 17 00:00:00 2001 From: abelvm Date: Wed, 17 Aug 2016 12:22:22 -0400 Subject: [PATCH 1/4] fix projection issues --- 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 970ec2f..476adb4 100644 --- a/src/pg/sql/09_voronoi.sql +++ b/src/pg/sql/09_voronoi.sql @@ -12,6 +12,15 @@ RETURNS geometry AS $$ DECLARE geomout geometry; BEGIN + -- we need to make the geometry calculations in (pseudo)meters!!! + with a as ( + SELECT unnest(geomin) as g1 + ), + b as( + SELECT st_transform(g1, 3857) g2 from a + ) + SELECT array_agg(g2) INTO geomin from b; + WITH convexhull_1 as ( SELECT @@ -138,8 +147,9 @@ BEGIN FROM voro_cells v ) SELECT - st_collect(ST_intersection(c.g, v.g)) - -- ST_intersection(c.g, v.g) + st_collect( + ST_Transform(ST_intersection(c.g, v.g), 4326) + ) INTO geomout FROM voro_set v, @@ -186,8 +196,8 @@ BEGIN RETURN NULL; END IF; IF ( ST_GeometryType(p_pt1) <> 'ST_Point' OR - ST_GeometryType(p_pt1) <> 'ST_Point' OR - ST_GeometryType(p_pt1) <> 'ST_Point' ) THEN + ST_GeometryType(p_pt2) <> 'ST_Point' OR + ST_GeometryType(p_pt3) <> 'ST_Point' ) THEN RAISE EXCEPTION 'All supplied geometries must be points.'; RETURN NULL; END IF; From d67f3951a75cd2b9cc0cfb0a5581e77caa6fb69a Mon Sep 17 00:00:00 2001 From: abelvm Date: Wed, 17 Aug 2016 12:32:17 -0400 Subject: [PATCH 2/4] fix test --- src/pg/test/expected/09_voronoi_test.out | 3 +-- src/pg/test/sql/09_voronoi_test.sql | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pg/test/expected/09_voronoi_test.out b/src/pg/test/expected/09_voronoi_test.out index 02a0400..99e9a9a 100644 --- a/src/pg/test/expected/09_voronoi_test.out +++ b/src/pg/test/expected/09_voronoi_test.out @@ -1,7 +1,6 @@ SET client_min_messages TO WARNING; \set ECHO none - avg_area + avg_area ---------------------- 0.000139602712846995 (1 row) - diff --git a/src/pg/test/sql/09_voronoi_test.sql b/src/pg/test/sql/09_voronoi_test.sql index a827350..032eeeb 100644 --- a/src/pg/test/sql/09_voronoi_test.sql +++ b/src/pg/test/sql/09_voronoi_test.sql @@ -3,7 +3,7 @@ SET client_min_messages TO WARNING; 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 ), b as( SELECT From e9ce87fb99771b1d3e4f750734aec33d7ebe70c9 Mon Sep 17 00:00:00 2001 From: abelvm Date: Wed, 17 Aug 2016 12:43:44 -0400 Subject: [PATCH 3/4] fix test out --- src/pg/test/expected/09_voronoi_test.out | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pg/test/expected/09_voronoi_test.out b/src/pg/test/expected/09_voronoi_test.out index 99e9a9a..f61c71e 100644 --- a/src/pg/test/expected/09_voronoi_test.out +++ b/src/pg/test/expected/09_voronoi_test.out @@ -1,6 +1,7 @@ SET client_min_messages TO WARNING; \set ECHO none - avg_area + avg_area ---------------------- - 0.000139602712846995 + 0.000200480682454162 (1 row) + From cbc505a62bc73631d305c50f002e4eca447edc11 Mon Sep 17 00:00:00 2001 From: abelvm Date: Wed, 17 Aug 2016 12:51:34 -0400 Subject: [PATCH 4/4] fix test out --- src/pg/test/expected/09_voronoi_test.out | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pg/test/expected/09_voronoi_test.out b/src/pg/test/expected/09_voronoi_test.out index f61c71e..1ccc695 100644 --- a/src/pg/test/expected/09_voronoi_test.out +++ b/src/pg/test/expected/09_voronoi_test.out @@ -1,7 +1,7 @@ SET client_min_messages TO WARNING; \set ECHO none - avg_area + avg_area ---------------------- 0.000200480682454162 (1 row) - +