PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ LWGEOM_numgeometries_collection()

Datum LWGEOM_numgeometries_collection ( PG_FUNCTION_ARGS  )

Definition at line 229 of file lwgeom_ogc.c.

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

Referenced by LWGEOM_numpoints_linestring().

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 }
unsigned int int32
Definition: shpopen.c:273
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
uint32_t ngeoms
Definition: liblwgeom.h:509
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:224
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: