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

Definition at line 412 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.

413 {
414  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
415  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
416  LWPOLY *poly = NULL;
417  LWCURVEPOLY *curvepoly = NULL;
418  int result = -1;
419 
420  if ( lwgeom->type == POLYGONTYPE )
421  {
422  poly = lwgeom_as_lwpoly(lwgeom);
423  result = poly->nrings - 1;
424  }
425  else if ( lwgeom->type == CURVEPOLYTYPE )
426  {
427  curvepoly = lwgeom_as_lwcurvepoly(lwgeom);
428  result = curvepoly->nrings - 1;
429  }
430 
431  lwgeom_free(lwgeom);
432  PG_FREE_IF_COPY(geom, 0);
433 
434  if ( result < 0 )
435  PG_RETURN_NULL();
436 
437  PG_RETURN_INT32(result);
438 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
LWCURVEPOLY * lwgeom_as_lwcurvepoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:129
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
Definition: lwgeom.c:138
int nrings
Definition: liblwgeom.h:454
uint8_t type
Definition: liblwgeom.h:395

Here is the call graph for this function: