PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_to_BOX2D()

Datum LWGEOM_to_BOX2D ( PG_FUNCTION_ARGS  )

Definition at line 102 of file lwgeom_box.c.

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

Referenced by BOX2D_out().

103 {
104  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
105  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
106  GBOX gbox;
107 
108  /* Cannot box empty! */
109  if ( lwgeom_is_empty(lwgeom) )
110  PG_RETURN_NULL();
111 
112  /* Cannot calculate box? */
113  if ( lwgeom_calculate_gbox(lwgeom, &gbox) == LW_FAILURE )
114  PG_RETURN_NULL();
115 
116  /* Strip out higher dimensions */
117  FLAGS_SET_Z(gbox.flags, 0);
118  FLAGS_SET_M(gbox.flags, 0);
119 
120  PG_FREE_IF_COPY(geom, 0);
121  PG_RETURN_POINTER(gbox_copy(&gbox));
122 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:403
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define LW_FAILURE
Definition: liblwgeom.h:64
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:652
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:130
uint8_t flags
Definition: liblwgeom.h:275
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:1297
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:131
Here is the call graph for this function:
Here is the caller graph for this function: