PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_numinteriorrings_polygon()

Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

Definition at line 411 of file lwgeom_ogc.c.

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

Referenced by LWGEOM_exteriorring_polygon().

412 {
413  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
414  int type = gserialized_get_type(geom);
415  LWGEOM *lwgeom;
416  int result = -1;
417 
418  if ( (type != POLYGONTYPE) &&
419  (type != CURVEPOLYTYPE) &&
420  (type != TRIANGLETYPE))
421  {
422  PG_RETURN_NULL();
423  }
424 
425  lwgeom = lwgeom_from_gserialized(geom);
426  if ( lwgeom_is_empty(lwgeom) )
427  {
428  result = 0;
429  }
430  else
431  {
432  const LWPOLY *poly = (LWPOLY*)lwgeom;
433  result = poly->nrings - 1;
434  }
435 
436  lwgeom_free(lwgeom);
437  PG_FREE_IF_COPY(geom, 0);
438 
439  if ( result < 0 )
440  PG_RETURN_NULL();
441 
442  PG_RETURN_INT32(result);
443 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:86
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
#define TRIANGLETYPE
Definition: liblwgeom.h:98
int nrings
Definition: liblwgeom.h:455
type
Definition: ovdump.py:41
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
Here is the call graph for this function:
Here is the caller graph for this function: