PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_numinteriorrings_polygon()

Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

Definition at line 412 of file lwgeom_ogc.c.

413 {
414  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
415  int type = gserialized_get_type(geom);
416  LWGEOM *lwgeom;
417  int result = -1;
418 
419  if ( (type != POLYGONTYPE) &&
420  (type != CURVEPOLYTYPE) &&
421  (type != TRIANGLETYPE))
422  {
423  PG_RETURN_NULL();
424  }
425 
426  lwgeom = lwgeom_from_gserialized(geom);
427  if ( lwgeom_is_empty(lwgeom) )
428  {
429  result = 0;
430  }
431  else
432  {
433  const LWPOLY *poly = (LWPOLY*)lwgeom;
434  result = poly->nrings - 1;
435  }
436 
437  lwgeom_free(lwgeom);
438  PG_FREE_IF_COPY(geom, 0);
439 
440  if ( result < 0 )
441  PG_RETURN_NULL();
442 
443  PG_RETURN_INT32(result);
444 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: g_serialized.c:86
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define POLYGONTYPE
Definition: liblwgeom.h:87
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwgeom.c:1393
#define TRIANGLETYPE
Definition: liblwgeom.h:98
type
Definition: ovdump.py:41
uint32_t nrings
Definition: liblwgeom.h:458

References CURVEPOLYTYPE, gserialized_get_type(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), LWPOLY::nrings, POLYGONTYPE, TRIANGLETYPE, and ovdump::type.

Here is the call graph for this function: