PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_numgeometries_collection()

Datum LWGEOM_numgeometries_collection ( PG_FUNCTION_ARGS  )

Definition at line 229 of file lwgeom_ogc.c.

230 {
231  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
232  LWGEOM *lwgeom;
233  int32 ret = 1;
234 
235  lwgeom = lwgeom_from_gserialized(geom);
236  if ( lwgeom_is_empty(lwgeom) )
237  {
238  ret = 0;
239  }
240  else if ( lwgeom_is_collection(lwgeom) )
241  {
242  LWCOLLECTION *col = lwgeom_as_lwcollection(lwgeom);
243  ret = col->ngeoms;
244  }
245  lwgeom_free(lwgeom);
246  PG_FREE_IF_COPY(geom, 0);
247  PG_RETURN_INT32(ret);
248 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
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
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:224
unsigned int int32
Definition: shpopen.c:273
uint32_t ngeoms
Definition: liblwgeom.h:510

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: