PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_to_BOX2D()

Datum LWGEOM_to_BOX2D ( PG_FUNCTION_ARGS  )

Definition at line 124 of file lwgeom_box.c.

125 {
126  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
127  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
128  GBOX gbox;
129 
130  /* Cannot box empty! */
131  if ( lwgeom_is_empty(lwgeom) )
132  PG_RETURN_NULL();
133 
134  /* Cannot calculate box? */
135  if ( lwgeom_calculate_gbox(lwgeom, &gbox) == LW_FAILURE )
136  PG_RETURN_NULL();
137 
138  /* Strip out higher dimensions */
139  FLAGS_SET_Z(gbox.flags, 0);
140  FLAGS_SET_M(gbox.flags, 0);
141 
142  PG_FREE_IF_COPY(geom, 0);
143  PG_RETURN_POINTER(gbox_copy(&gbox));
144 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:433
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define LW_FAILURE
Definition: liblwgeom.h:79
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:1393
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:746
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:147
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:146
uint8_t flags
Definition: liblwgeom.h:294

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: