PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

Definition at line 403 of file lwgeom_ogc.c.

References CURVEPOLYTYPE, lwgeom_as_lwcurvepoly(), lwgeom_as_lwpoly(), lwgeom_free(), lwgeom_from_gserialized(), LWPOLY::nrings, LWCURVEPOLY::nrings, POLYGONTYPE, result, and LWGEOM::type.

404 {
405  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
406  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
407  LWPOLY *poly = NULL;
408  LWCURVEPOLY *curvepoly = NULL;
409  int result = -1;
410 
411  if ( lwgeom->type == POLYGONTYPE )
412  {
413  poly = lwgeom_as_lwpoly(lwgeom);
414  result = poly->nrings - 1;
415  }
416  else if ( lwgeom->type == CURVEPOLYTYPE )
417  {
418  curvepoly = lwgeom_as_lwcurvepoly(lwgeom);
419  result = curvepoly->nrings - 1;
420  }
421 
422  lwgeom_free(lwgeom);
423  PG_FREE_IF_COPY(geom, 0);
424 
425  if ( result < 0 )
426  PG_RETURN_NULL();
427 
428  PG_RETURN_INT32(result);
429 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:116
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:125
char ** result
Definition: liblwgeom.h:218
LWGEOM * geom
int nrings
Definition: liblwgeom.h:411
uint8_t type
Definition: liblwgeom.h:352

Here is the call graph for this function: