PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_numgeometries_collection()

Datum LWGEOM_numgeometries_collection ( PG_FUNCTION_ARGS  )

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

229 {
230  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
231  LWGEOM *lwgeom;
232  int32 ret = 1;
233 
234  lwgeom = lwgeom_from_gserialized(geom);
235  if ( lwgeom_is_empty(lwgeom) )
236  {
237  ret = 0;
238  }
239  else if ( lwgeom_is_collection(lwgeom) )
240  {
241  LWCOLLECTION *col = lwgeom_as_lwcollection(lwgeom);
242  ret = col->ngeoms;
243  }
244  lwgeom_free(lwgeom);
245  PG_FREE_IF_COPY(geom, 0);
246  PG_RETURN_INT32(ret);
247 }
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:1040
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:192
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: