PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_add_bbox_deep()

void lwgeom_add_bbox_deep ( LWGEOM lwgeom,
GBOX gbox 
)

Compute a box for geom and all sub-geometries, if not already computed.

Definition at line 705 of file lwgeom.c.

706 {
707  if ( lwgeom_is_empty(lwgeom) ) return;
708 
709  FLAGS_SET_BBOX(lwgeom->flags, 1);
710 
711  if ( ! ( gbox || lwgeom->bbox ) )
712  {
713  lwgeom->bbox = gbox_new(lwgeom->flags);
714  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
715  }
716  else if ( gbox && ! lwgeom->bbox )
717  {
718  lwgeom->bbox = gbox_clone(gbox);
719  }
720 
721  if ( lwgeom_is_collection(lwgeom) )
722  {
723  uint32_t i;
724  LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
725 
726  for ( i = 0; i < lwcol->ngeoms; i++ )
727  {
728  lwgeom_add_bbox_deep(lwcol->geoms[i], lwgeom->bbox);
729  }
730  }
731 }
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: g_box.c:39
GBOX * gbox_clone(const GBOX *gbox)
Definition: g_box.c:52
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:148
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
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 the gbox for this geometry, a cartesian box or geodetic box, depending on how it is flagged...
Definition: lwgeom.c:746
void lwgeom_add_bbox_deep(LWGEOM *lwgeom, GBOX *gbox)
Compute a box for geom and all sub-geometries, if not already computed.
Definition: lwgeom.c:705
uint32_t ngeoms
Definition: liblwgeom.h:510
LWGEOM ** geoms
Definition: liblwgeom.h:512
GBOX * bbox
Definition: liblwgeom.h:401
uint8_t flags
Definition: liblwgeom.h:400
unsigned int uint32_t
Definition: uthash.h:78

References LWGEOM::bbox, LWGEOM::flags, FLAGS_SET_BBOX, gbox_clone(), gbox_new(), LWCOLLECTION::geoms, lwgeom_add_bbox_deep(), lwgeom_calculate_gbox(), lwgeom_is_collection(), lwgeom_is_empty(), and LWCOLLECTION::ngeoms.

Referenced by geography_distance_knn(), geography_distance_uncached(), and lwgeom_add_bbox_deep().

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