PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ LWGEOM_numinteriorrings_polygon()

Datum LWGEOM_numinteriorrings_polygon ( PG_FUNCTION_ARGS  )

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

413 {
414  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
415  int type = gserialized_get_type(geom);
416  LWGEOM *lwgeom;
417  int result = -1;
418 
419  if ( (type != POLYGONTYPE) &&
420  (type != CURVEPOLYTYPE) &&
421  (type != TRIANGLETYPE))
422  {
423  PG_RETURN_NULL();
424  }
425 
426  lwgeom = lwgeom_from_gserialized(geom);
427  if ( lwgeom_is_empty(lwgeom) )
428  {
429  result = 0;
430  }
431  else
432  {
433  const LWPOLY *poly = (LWPOLY*)lwgeom;
434  result = poly->nrings - 1;
435  }
436 
437  lwgeom_free(lwgeom);
438  PG_FREE_IF_COPY(geom, 0);
439 
440  if ( result < 0 )
441  PG_RETURN_NULL();
442 
443  PG_RETURN_INT32(result);
444 }
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:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t nrings
Definition: liblwgeom.h:457
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:1393
Here is the call graph for this function:
Here is the caller graph for this function: