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

Definition at line 284 of file lwgeom_box3d.c.

References box3d_from_gbox(), LW_FAILURE, lwgeom_calculate_gbox(), lwgeom_free(), lwgeom_from_gserialized(), result, BOX3D::srid, and LWGEOM::srid.

285 {
286  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
287  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
288  GBOX gbox;
289  BOX3D *result;
290  int rv = lwgeom_calculate_gbox(lwgeom, &gbox);
291 
292  if ( rv == LW_FAILURE )
293  PG_RETURN_NULL();
294 
295  result = box3d_from_gbox(&gbox);
296  result->srid = lwgeom->srid;
297 
298  lwgeom_free(lwgeom);
299  PG_RETURN_POINTER(result);
300 }
int32_t srid
Definition: liblwgeom.h:235
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
int32_t srid
Definition: liblwgeom.h:355
#define LW_FAILURE
Definition: liblwgeom.h:54
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
Definition: lwgeom.c:608
BOX3D * box3d_from_gbox(const GBOX *gbox)
Definition: g_box.c:47

Here is the call graph for this function: