PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 698 of file lwgeom.c.

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

Referenced by geography_distance_knn(), and geography_distance_uncached().

699 {
700  if ( lwgeom_is_empty(lwgeom) ) return;
701 
702  FLAGS_SET_BBOX(lwgeom->flags, 1);
703 
704  if ( ! ( gbox || lwgeom->bbox ) )
705  {
706  lwgeom->bbox = gbox_new(lwgeom->flags);
707  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
708  }
709  else if ( gbox && ! lwgeom->bbox )
710  {
711  lwgeom->bbox = gbox_clone(gbox);
712  }
713 
714  if ( lwgeom_is_collection(lwgeom) )
715  {
716  uint32_t i;
717  LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
718 
719  for ( i = 0; i < lwcol->ngeoms; i++ )
720  {
721  lwgeom_add_bbox_deep(lwcol->geoms[i], lwgeom->bbox);
722  }
723  }
724 }
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: g_box.c:39
GBOX * bbox
Definition: liblwgeom.h:397
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:698
uint8_t flags
Definition: liblwgeom.h:396
uint32_t ngeoms
Definition: liblwgeom.h:506
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:508
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:1386
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:147
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1078
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:739
GBOX * gbox_clone(const GBOX *gbox)
Definition: g_box.c:52

Here is the call graph for this function:

Here is the caller graph for this function: