PostGIS  3.1.6dev-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 697 of file lwgeom.c.

698 {
699  if ( lwgeom_is_empty(lwgeom) ) return;
700 
701  FLAGS_SET_BBOX(lwgeom->flags, 1);
702 
703  if ( ! ( gbox || lwgeom->bbox ) )
704  {
705  lwgeom->bbox = gbox_new(lwgeom->flags);
706  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
707  }
708  else if ( gbox && ! lwgeom->bbox )
709  {
710  lwgeom->bbox = gbox_clone(gbox);
711  }
712 
713  if ( lwgeom_is_collection(lwgeom) )
714  {
715  uint32_t i;
716  LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
717 
718  for ( i = 0; i < lwcol->ngeoms; i++ )
719  {
720  lwgeom_add_bbox_deep(lwcol->geoms[i], lwgeom->bbox);
721  }
722  }
723 }
GBOX * gbox_new(lwflags_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: gbox.c:32
GBOX * gbox_clone(const GBOX *gbox)
Definition: gbox.c:45
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:188
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1080
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:738
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:697
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:203
uint32_t ngeoms
Definition: liblwgeom.h:594
LWGEOM ** geoms
Definition: liblwgeom.h:589
GBOX * bbox
Definition: liblwgeom.h:472
lwflags_t flags
Definition: liblwgeom.h:475

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: