PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwgeom_add_bbox()

void lwgeom_add_bbox ( LWGEOM lwgeom)

Compute a bbox if not already computed.

After calling this function lwgeom->bbox is only NULL if the geometry is empty.

Compute a bbox if not already computed.

If the box is already there just return, else compute it.

Definition at line 677 of file lwgeom.c.

678 {
679  /* an empty LWGEOM has no bbox */
680  if ( lwgeom_is_empty(lwgeom) ) return;
681 
682  if ( lwgeom->bbox ) return;
683  FLAGS_SET_BBOX(lwgeom->flags, 1);
684  lwgeom->bbox = gbox_new(lwgeom->flags);
685  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
686 }
GBOX * gbox_new(lwflags_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: gbox.c:32
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:188
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the gbox for this geometry, a cartesian box or geodetic box, depending on how it is flagged...
Definition: lwgeom.c:737
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
GBOX * bbox
Definition: liblwgeom.h:444
lwflags_t flags
Definition: liblwgeom.h:447

References LWGEOM::bbox, LWGEOM::flags, FLAGS_SET_BBOX, gbox_new(), lwgeom_calculate_gbox(), and lwgeom_is_empty().

Referenced by do_lwgeom_swap_ordinates(), geom_from_kml(), GEOS2POSTGIS(), gserialized1_from_lwgeom(), gserialized2_from_lwgeom(), lw_dist2d_recursive(), LWGEOM_addBBOX(), LWGEOM_ChaikinSmoothing(), LWGEOM_expand(), lwgeom_from_encoded_polyline(), lwgeom_from_geojson(), LWGEOM_geometryn_collection(), lwgeom_get_bbox(), LWGEOM_in(), LWGEOM_recv(), lwgeom_refresh_bbox(), LWGEOM_SetEffectiveArea(), LWGEOMFromEWKB(), LWGEOMFromTWKB(), lwline_removepoint(), lwpoly_construct_envelope(), lwt_ChangeEdgeGeom(), SFCGALGeometry2POSTGIS(), test_gbox_same_2d(), test_lwgeom_from_gserialized(), test_lwgeom_from_gserialized2(), test_lwgeom_same(), and test_lwgeom_scale().

Here is the call graph for this function:
Here is the caller graph for this function: