PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ LWGEOM_numinteriorrings_polygon()

Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

Definition at line 420 of file lwgeom_ogc.c.

421 {
422  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
423  int type = gserialized_get_type(geom);
424  LWGEOM *lwgeom;
425  int result = -1;
426 
427  if ( (type != POLYGONTYPE) &&
428  (type != CURVEPOLYTYPE) &&
429  (type != TRIANGLETYPE))
430  {
431  PG_RETURN_NULL();
432  }
433 
434  lwgeom = lwgeom_from_gserialized(geom);
435  if ( lwgeom_is_empty(lwgeom) || type == TRIANGLETYPE )
436  {
437  result = 0;
438  }
439  else
440  {
441  const LWPOLY *poly = (LWPOLY*)lwgeom;
442  result = poly->nrings - 1;
443  }
444 
445  lwgeom_free(lwgeom);
446  PG_FREE_IF_COPY(geom, 0);
447 
448  if ( result < 0 )
449  PG_RETURN_NULL();
450 
451  PG_RETURN_INT32(result);
452 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
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:203
type
Definition: ovdump.py:42
uint32_t nrings
Definition: liblwgeom.h:538

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

Here is the call graph for this function: