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

Definition at line 398 of file lwgeom_ogc.c.

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

399 {
400  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
401  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
402  LWPOLY *poly = NULL;
403  LWCURVEPOLY *curvepoly = NULL;
404  int result = -1;
405 
406  if ( lwgeom->type == POLYGONTYPE )
407  {
408  poly = lwgeom_as_lwpoly(lwgeom);
409  result = poly->nrings - 1;
410  }
411  else if ( lwgeom->type == CURVEPOLYTYPE )
412  {
413  curvepoly = lwgeom_as_lwcurvepoly(lwgeom);
414  result = curvepoly->nrings - 1;
415  }
416 
417  lwgeom_free(lwgeom);
418  PG_FREE_IF_COPY(geom, 0);
419 
420  if ( result < 0 )
421  PG_RETURN_NULL();
422 
423  PG_RETURN_INT32(result);
424 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:116
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:125
int nrings
Definition: liblwgeom.h:439
uint8_t type
Definition: liblwgeom.h:380

Here is the call graph for this function: