PostGIS  3.0.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 696 of file lwgeom.c.

697 {
698  if ( lwgeom_is_empty(lwgeom) ) return;
699 
700  FLAGS_SET_BBOX(lwgeom->flags, 1);
701 
702  if ( ! ( gbox || lwgeom->bbox ) )
703  {
704  lwgeom->bbox = gbox_new(lwgeom->flags);
705  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
706  }
707  else if ( gbox && ! lwgeom->bbox )
708  {
709  lwgeom->bbox = gbox_clone(gbox);
710  }
711 
712  if ( lwgeom_is_collection(lwgeom) )
713  {
714  uint32_t i;
715  LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
716 
717  for ( i = 0; i < lwcol->ngeoms; i++ )
718  {
719  lwgeom_add_bbox_deep(lwcol->geoms[i], lwgeom->bbox);
720  }
721  }
722 }
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:1079
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
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:696
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
uint32_t ngeoms
Definition: liblwgeom.h:566
LWGEOM ** geoms
Definition: liblwgeom.h:561
GBOX * bbox
Definition: liblwgeom.h:444
lwflags_t flags
Definition: liblwgeom.h:447

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: