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

Definition at line 293 of file lwgeom_ogc.c.

References lwgeom_dimension(), lwgeom_free(), and lwgeom_from_gserialized().

294 {
295  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
296  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
297  int dimension = -1;
298 
299  dimension = lwgeom_dimension(lwgeom);
300  lwgeom_free(lwgeom);
301  PG_FREE_IF_COPY(geom, 0);
302 
303  if ( dimension < 0 )
304  {
305  elog(NOTICE, "Could not compute geometry dimensions");
306  PG_RETURN_NULL();
307  }
308 
309  PG_RETURN_INT32(dimension);
310 }
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
int lwgeom_dimension(const LWGEOM *geom)
For an LWGEOM, returns 0 for points, 1 for lines, 2 for polygons, 3 for volume, and the max dimension...
Definition: lwgeom.c:1124

Here is the call graph for this function: