PostGIS  2.3.8dev-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 612 of file lwgeom.c.

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

Referenced by do_lwgeom_flip_coordinates(), geom_from_kml(), geometry_from_geography(), GEOS2POSTGIS(), gserialized_from_lwgeom(), lw_dist2d_recursive(), LWGEOM_addBBOX(), LWGEOM_affine(), LWGEOM_expand(), lwgeom_from_encoded_polyline(), lwgeom_from_geojson(), lwgeom_from_gml(), LWGEOM_from_WKB(), LWGEOM_geometryn_collection(), lwgeom_get_bbox(), LWGEOM_in(), LWGEOM_recv(), LWGEOM_SetEffectiveArea(), LWGEOM_simplify2d(), LWGEOM_snaptogrid(), LWGEOM_snaptogrid_pointoff(), lwgeom_swap_ordinates(), LWGEOMFromEWKB(), LWGEOMFromTWKB(), lwline_add_lwpoint(), lwline_clip_to_ordinate_range(), lwline_removepoint(), lwline_setPoint4d(), lwmline_clip_to_ordinate_range(), lwmpoint_clip_to_ordinate_range(), lwpoint_clip_to_ordinate_range(), lwt_ChangeEdgeGeom(), SFCGALGeometry2POSTGIS(), ST_MakeEnvelope(), test_gbox_same_2d(), test_lwgeom_from_gserialized(), test_lwgeom_same(), test_lwgeom_scale(), transform(), and transform_geom().

613 {
614  /* an empty LWGEOM has no bbox */
615  if ( lwgeom_is_empty(lwgeom) ) return;
617  if ( lwgeom->bbox ) return;
618  FLAGS_SET_BBOX(lwgeom->flags, 1);
619  lwgeom->bbox = gbox_new(lwgeom->flags);
620  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
621 }
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: g_box.c:43
GBOX * bbox
Definition: liblwgeom.h:397
uint8_t flags
Definition: liblwgeom.h:396
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:1310
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:147
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the gbox for this goemetry, a cartesian box or geodetic box, depending on how it is flagged...
Definition: lwgeom.c:665
Here is the call graph for this function:
Here is the caller graph for this function: