PostGIS  2.2.8dev-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 611 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().

612 {
613  if ( lwgeom_is_empty(lwgeom) ) return;
614 
615  FLAGS_SET_BBOX(lwgeom->flags, 1);
616 
617  if ( ! ( gbox || lwgeom->bbox ) )
618  {
619  lwgeom->bbox = gbox_new(lwgeom->flags);
620  lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
621  }
622  else if ( gbox && ! lwgeom->bbox )
623  {
624  lwgeom->bbox = gbox_clone(gbox);
625  }
626 
627  if ( lwgeom_is_collection(lwgeom) )
628  {
629  int i;
630  LWCOLLECTION *lwcol = (LWCOLLECTION*)lwgeom;
631 
632  for ( i = 0; i < lwcol->ngeoms; i++ )
633  {
634  lwgeom_add_bbox_deep(lwcol->geoms[i], lwgeom->bbox);
635  }
636  }
637 }
GBOX * gbox_new(uint8_t flags)
Create a new gbox with the dimensionality indicated by the flags.
Definition: g_box.c:28
GBOX * bbox
Definition: liblwgeom.h:382
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:611
uint8_t flags
Definition: liblwgeom.h:381
LWGEOM ** geoms
Definition: liblwgeom.h:493
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:1297
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:132
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
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:652
GBOX * gbox_clone(const GBOX *gbox)
Definition: g_box.c:41
Here is the call graph for this function:
Here is the caller graph for this function: