PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ LWGEOM_to_BOX2D()

Datum LWGEOM_to_BOX2D ( PG_FUNCTION_ARGS  )

Definition at line 122 of file lwgeom_box.c.

123 {
124  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
125  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
126  GBOX gbox;
127 
128  /* Cannot box empty! */
129  if ( lwgeom_is_empty(lwgeom) )
130  PG_RETURN_NULL();
131 
132  /* Cannot calculate box? */
133  if ( lwgeom_calculate_gbox(lwgeom, &gbox) == LW_FAILURE )
134  PG_RETURN_NULL();
135 
136  /* Strip out higher dimensions */
137  FLAGS_SET_Z(gbox.flags, 0);
138  FLAGS_SET_M(gbox.flags, 0);
139 
140  PG_FREE_IF_COPY(geom, 0);
141  PG_RETURN_POINTER(gbox_copy(&gbox));
142 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: gbox.c:426
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
#define LW_FAILURE
Definition: liblwgeom.h:110
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:737
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:187
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:186
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:193
lwflags_t flags
Definition: liblwgeom.h:339

References GBOX::flags, FLAGS_SET_M, FLAGS_SET_Z, gbox_copy(), LW_FAILURE, lwgeom_calculate_gbox(), lwgeom_from_gserialized(), and lwgeom_is_empty().

Here is the call graph for this function: