PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_numgeometries_collection ( PG_FUNCTION_ARGS  )

Definition at line 219 of file lwgeom_ogc.c.

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

220 {
221  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
222  LWGEOM *lwgeom;
223  int32 ret = 1;
224 
225  lwgeom = lwgeom_from_gserialized(geom);
226  if ( lwgeom_is_empty(lwgeom) )
227  {
228  ret = 0;
229  }
230  else if ( lwgeom_is_collection(lwgeom) )
231  {
232  LWCOLLECTION *col = lwgeom_as_lwcollection(lwgeom);
233  ret = col->ngeoms;
234  }
235  lwgeom_free(lwgeom);
236  PG_FREE_IF_COPY(geom, 0);
237  PG_RETURN_INT32(ret);
238 }
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:947
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * geom
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:143
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:1229

Here is the call graph for this function: