PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ LWGEOM_numinteriorrings_polygon()

Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

Definition at line 425 of file lwgeom_ogc.c.

426 {
427  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
428  int type = gserialized_get_type(geom);
429  LWGEOM *lwgeom;
430  int result = -1;
431 
432  if ( (type != POLYGONTYPE) &&
433  (type != CURVEPOLYTYPE) &&
434  (type != TRIANGLETYPE))
435  {
436  PG_RETURN_NULL();
437  }
438 
439  lwgeom = lwgeom_from_gserialized(geom);
440  if ( lwgeom_is_empty(lwgeom) )
441  {
442  result = 0;
443  }
444  else
445  {
446  const LWPOLY *poly = (LWPOLY*)lwgeom;
447  result = poly->nrings - 1;
448  }
449 
450  lwgeom_free(lwgeom);
451  PG_FREE_IF_COPY(geom, 0);
452 
453  if ( result < 0 )
454  PG_RETURN_NULL();
455 
456  PG_RETURN_INT32(result);
457 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
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:1155
#define CURVEPOLYTYPE
Definition: liblwgeom.h:111
#define POLYGONTYPE
Definition: liblwgeom.h:104
#define TRIANGLETYPE
Definition: liblwgeom.h:115
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:524

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: