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

Definition at line 214 of file lwgeom_ogc.c.

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

215 {
216  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
217  LWGEOM *lwgeom;
218  int32 ret = 1;
219 
220  lwgeom = lwgeom_from_gserialized(geom);
221  if ( lwgeom_is_empty(lwgeom) )
222  {
223  ret = 0;
224  }
225  else if ( lwgeom_is_collection(lwgeom) )
226  {
227  LWCOLLECTION *col = lwgeom_as_lwcollection(lwgeom);
228  ret = col->ngeoms;
229  }
230  lwgeom_free(lwgeom);
231  PG_FREE_IF_COPY(geom, 0);
232  PG_RETURN_INT32(ret);
233 }
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:991
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
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:1297

Here is the call graph for this function: