PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_to_BOX2D()

Datum LWGEOM_to_BOX2D ( PG_FUNCTION_ARGS  )

Definition at line 129 of file lwgeom_box.c.

130{
131 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
132 LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
133 GBOX gbox;
134
135 /* Cannot box empty! */
136 if ( lwgeom_is_empty(lwgeom) )
137 PG_RETURN_NULL();
138
139 /* Cannot calculate box? */
140 if ( lwgeom_calculate_gbox(lwgeom, &gbox) == LW_FAILURE )
141 PG_RETURN_NULL();
142
143 /* Strip out higher dimensions */
144 FLAGS_SET_Z(gbox.flags, 0);
145 FLAGS_SET_M(gbox.flags, 0);
146
147 PG_FREE_IF_COPY(geom, 0);
148 PG_RETURN_POINTER(gbox_copy(&gbox));
149}
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition gbox.c:438
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define LW_FAILURE
Definition liblwgeom.h:96
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:783
#define FLAGS_SET_M(flags, value)
Definition liblwgeom.h:173
#define FLAGS_SET_Z(flags, value)
Definition liblwgeom.h:172
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:199
lwflags_t flags
Definition liblwgeom.h:353

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: