PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ LWGEOM_numinteriorrings_polygon()

Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

Definition at line 419 of file lwgeom_ogc.c.

420 {
421  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
422  int type = gserialized_get_type(geom);
423  LWGEOM *lwgeom;
424  int result = -1;
425 
426  if ( (type != POLYGONTYPE) &&
427  (type != CURVEPOLYTYPE) &&
428  (type != TRIANGLETYPE))
429  {
430  PG_RETURN_NULL();
431  }
432 
433  lwgeom = lwgeom_from_gserialized(geom);
434  if ( lwgeom_is_empty(lwgeom) )
435  {
436  result = 0;
437  }
438  else
439  {
440  const LWPOLY *poly = (LWPOLY*)lwgeom;
441  result = poly->nrings - 1;
442  }
443 
444  lwgeom_free(lwgeom);
445  PG_FREE_IF_COPY(geom, 0);
446 
447  if ( result < 0 )
448  PG_RETURN_NULL();
449 
450  PG_RETURN_INT32(result);
451 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define CURVEPOLYTYPE
Definition: liblwgeom.h:125
#define POLYGONTYPE
Definition: liblwgeom.h:118
#define TRIANGLETYPE
Definition: liblwgeom.h:129
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:193
type
Definition: ovdump.py:42
uint32_t nrings
Definition: liblwgeom.h:510

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: