PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lwgeom_concavehull()

LWGEOM* lwgeom_concavehull ( const LWGEOM geom,
double  ratio,
uint32_t  allow_holes 
)

Take a geometry and build the concave hull.

The concave hull is smaller than the convex hull, but still encompasses all the points of the input. For polygon input the hull encompasses all the input area. For line input the hull encompasses all the input lines.

Parameters
gthe input geometry
ratioproportion of output vs input
allow_holescan there be holes in the output. large performance penalty.

Definition at line 2151 of file liblwgeom/lwgeom_geos.c.

2152 {
2153  LWGEOM* result;
2154  int32_t srid = RESULT_SRID(geom);
2155  uint8_t is3d = FLAGS_GET_Z(geom->flags);
2156  GEOSGeometry *g1, *g3;
2157  int geosGeomType;
2158 
2159  initGEOS(lwnotice, lwgeom_geos_error);
2160 
2161  if (!(g1 = LWGEOM2GEOS(geom, AUTOFIX))) GEOS_FAIL();
2162 
2163  geosGeomType = GEOSGeomTypeId(g1);
2164  if (geosGeomType == GEOS_POLYGON || geosGeomType == GEOS_MULTIPOLYGON) {
2165  int is_tight = LW_FALSE;
2166  g3 = GEOSConcaveHullOfPolygons(g1, ratio, is_tight, allow_holes);
2167  }
2168  else {
2169  g3 = GEOSConcaveHull(g1, ratio, allow_holes);
2170  }
2171 
2172  if (!g3)
2173  GEOS_FREE_AND_FAIL(g1);
2174 
2175  GEOSSetSRID(g3, srid);
2176 
2177  if (!(result = GEOS2LWGEOM(g3, is3d)))
2178  GEOS_FREE_AND_FAIL(g1, g3);
2179 
2180  GEOS_FREE(g1, g3);
2181  return result;
2182 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
#define GEOS_FREE(...)
#define AUTOFIX
#define RESULT_SRID(...)
#define GEOS_FAIL()
#define GEOS_FREE_AND_FAIL(...)
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
#define LW_FALSE
Definition: liblwgeom.h:94
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:165
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
lwflags_t flags
Definition: liblwgeom.h:461

References AUTOFIX, LWGEOM::flags, FLAGS_GET_Z, GEOS2LWGEOM(), GEOS_FAIL, GEOS_FREE, GEOS_FREE_AND_FAIL, LW_FALSE, LWGEOM2GEOS(), lwgeom_geos_error(), lwnotice(), result, and RESULT_SRID.

Referenced by ST_ConcaveHull().

Here is the call graph for this function:
Here is the caller graph for this function: