[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0alpha1-18-g4ad1e66b1
git at osgeo.org
git at osgeo.org
Thu Jun 9 10:35:35 PDT 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via 4ad1e66b123d76e7dd3127660b8da13ce1942978 (commit)
from 50f0801edf94b9f99af34bc9fcdd4826ca9ee994 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4ad1e66b123d76e7dd3127660b8da13ce1942978
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Thu Jun 9 10:34:16 2022 -0700
Expose GEOS polygonal concave hull in ST_ConcaveHull, closes #5168.
The current concave hull does a "pointwise" hull.
For polygonal inputs, this can result in a hull that does
not cover all the area of the input. The polygonal hull
algorithm ensures that the hull in fact covers all the
input area.
diff --git a/doc/reference_processing.xml b/doc/reference_processing.xml
index bd5135038..d30300b68 100644
--- a/doc/reference_processing.xml
+++ b/doc/reference_processing.xml
@@ -654,12 +654,14 @@ POINT(0.5 1)
but often values between 0.3 and 0.1 produce reasonable results.
</para>
- <para>Technically, the target percent determines a length as a fraction of the difference between
+ <para>Technically, the <varname>param_pctconvex</varname> determines a length as a fraction of the difference between
the longest and shortest edges in the Delaunay Triangulation of the input points.
Edges longer than this length are "eroded" from the triangulation.
The triangles remaining form the concave hull.
</para>
+ <para>For point and linear inputs, the hull will enclose all the points of the inputs. For polygonal inputs, the hull will enclose all the points of the input <emphasis>and also</emphasis> all the areas covered by the input. If you want a point-wise hull of a polygonal input, convert it to points first, using <xref linkend="ST_Points" />.</para>
+
<para>This is not an aggregate function.
To compute the concave hull of a set of geometries use <xref linkend="ST_Collect" />
(e.g. <code>ST_ConcaveHull( ST_Collect( geom ), 0.80)</code>.</para>
diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c
index e3f321e04..b0c7fe7b3 100644
--- a/liblwgeom/lwgeom_geos.c
+++ b/liblwgeom/lwgeom_geos.c
@@ -2100,12 +2100,20 @@ lwgeom_concavehull(const LWGEOM* geom, double ratio, uint32_t allow_holes)
int32_t srid = RESULT_SRID(geom);
uint8_t is3d = FLAGS_GET_Z(geom->flags);
GEOSGeometry *g1, *g3;
+ int geosGeomType;
initGEOS(lwnotice, lwgeom_geos_error);
if (!(g1 = LWGEOM2GEOS(geom, AUTOFIX))) GEOS_FAIL();
- g3 = GEOSConcaveHull(g1, ratio, allow_holes);
+ geosGeomType = GEOSGeomTypeId(g1);
+ if (geosGeomType == GEOS_POLYGON || geosGeomType == GEOS_MULTIPOLYGON) {
+ int is_tight = LW_FALSE;
+ g3 = GEOSConcaveHullOfPolygons(g1, ratio, is_tight, allow_holes);
+ }
+ else {
+ g3 = GEOSConcaveHull(g1, ratio, allow_holes);
+ }
if (!g3)
GEOS_FREE_AND_FAIL(g1);
diff --git a/regress/core/geos311.sql b/regress/core/geos311.sql
index f2eafd51c..7e9b4aa49 100644
--- a/regress/core/geos311.sql
+++ b/regress/core/geos311.sql
@@ -3,7 +3,7 @@
WITH hull AS (
SELECT ST_Buffer(ST_MakePoint(0,0),1) AS geom
)
-SELECT 'concavehull01',
+SELECT 'concavehull01-poly' as test,
abs(ST_Area(geom) - ST_Area(ST_ConcaveHull(geom, 1.0))) < 0.01 AS area_convex
FROM hull;
@@ -12,8 +12,28 @@ WITH hull AS (
ST_Buffer(ST_MakePoint(0,0),10),
ST_Translate(ST_Buffer(ST_MakePoint(0,0),10), 5, 0)) AS geom
)
-SELECT 'concavehull02',
+SELECT 'concavehull02-poly' as test,
ST_Area(ST_ConcaveHull(geom, 0.5)) > 0.0 AS area_non_zero,
ST_GeometryType(ST_ConcaveHull(geom, 0.5)) AS type,
ST_Area(ST_ConcaveHull(geom, 0.5, true)) > 0.0 AS nohole_area_non_zero
FROM hull;
+
+-- ST_ConcaveHull --
+WITH hull AS (
+ SELECT ST_Buffer(ST_MakePoint(0,0),1) AS geom
+)
+SELECT 'concavehull01-points' as test,
+ abs(ST_Area(geom) - ST_Area(ST_ConcaveHull(ST_Points(geom), 1.0))) < 0.01 AS area_convex
+FROM hull;
+
+WITH hull AS (
+ SELECT ST_Difference(
+ ST_Buffer(ST_MakePoint(0,0),10),
+ ST_Translate(ST_Buffer(ST_MakePoint(0,0),10), 5, 0)) AS geom
+)
+SELECT 'concavehull02-points' as test,
+ ST_Area(ST_ConcaveHull(ST_Points(geom), 0.5)) > 0.0 AS area_non_zero,
+ ST_GeometryType(ST_ConcaveHull(ST_Points(geom), 0.5)) AS type,
+ ST_Area(ST_ConcaveHull(ST_Points(geom), 0.5, true)) > 0.0 AS nohole_area_non_zero
+FROM hull;
+
diff --git a/regress/core/geos311_expected b/regress/core/geos311_expected
index b42456e4e..59c2e49af 100644
--- a/regress/core/geos311_expected
+++ b/regress/core/geos311_expected
@@ -1,2 +1,4 @@
-concavehull01|t
-concavehull02|t|ST_Polygon|t
+concavehull01-poly|t
+concavehull02-poly|t|ST_Polygon|t
+concavehull01-points|t
+concavehull02-points|t|ST_Polygon|t
-----------------------------------------------------------------------
Summary of changes:
doc/reference_processing.xml | 4 +++-
liblwgeom/lwgeom_geos.c | 10 +++++++++-
regress/core/geos311.sql | 24 ++++++++++++++++++++++--
regress/core/geos311_expected | 6 ++++--
4 files changed, 38 insertions(+), 6 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list