PostGIS  3.4.0dev-r@@SVN_REVISION@@
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages

◆ LWGEOM_numgeometries_collection()

Datum LWGEOM_numgeometries_collection ( PG_FUNCTION_ARGS  )

Definition at line 237 of file lwgeom_ogc.c.

238 {
239  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
240  LWGEOM *lwgeom;
241  int32 ret = 1;
242 
243  lwgeom = lwgeom_from_gserialized(geom);
244  if (lwgeom_is_empty(lwgeom))
245  {
246  ret = 0;
247  }
248  else if (lwgeom_is_collection(lwgeom))
249  {
250  LWCOLLECTION *col = lwgeom_as_lwcollection(lwgeom);
251  ret = col->ngeoms;
252  }
253  lwgeom_free(lwgeom);
254  PG_FREE_IF_COPY(geom, 0);
255  PG_RETURN_INT32(ret);
256 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1097
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:233
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
unsigned int int32
Definition: shpopen.c:54
uint32_t ngeoms
Definition: liblwgeom.h:580

References lwgeom_as_lwcollection(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_collection(), lwgeom_is_empty(), and LWCOLLECTION::ngeoms.

Here is the call graph for this function: