PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcollection_calculate_gbox_cartesian()

static int lwcollection_calculate_gbox_cartesian ( LWCOLLECTION coll,
GBOX gbox 
)
static

Definition at line 613 of file g_box.c.

References GBOX::flags, LWCOLLECTION::flags, gbox_duplicate(), gbox_merge(), LWCOLLECTION::geoms, LW_FAILURE, LW_FALSE, LW_SUCCESS, LW_TRUE, lwgeom_calculate_gbox_cartesian(), and LWCOLLECTION::ngeoms.

Referenced by lwgeom_calculate_gbox_cartesian().

614 {
615  GBOX subbox;
616  int i;
617  int result = LW_FAILURE;
618  int first = LW_TRUE;
619  assert(coll);
620  if ( (coll->ngeoms == 0) || !gbox)
621  return LW_FAILURE;
622 
623  subbox.flags = coll->flags;
624 
625  for ( i = 0; i < coll->ngeoms; i++ )
626  {
627  if ( lwgeom_calculate_gbox_cartesian((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
628  {
629  /* Keep a copy of the sub-bounding box for later
630  if ( coll->geoms[i]->bbox )
631  lwfree(coll->geoms[i]->bbox);
632  coll->geoms[i]->bbox = gbox_copy(&subbox); */
633  if ( first )
634  {
635  gbox_duplicate(&subbox, gbox);
636  first = LW_FALSE;
637  }
638  else
639  {
640  gbox_merge(&subbox, gbox);
641  }
642  result = LW_SUCCESS;
643  }
644  }
645  return result;
646 }
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
Definition: g_box.c:410
#define LW_SUCCESS
Definition: liblwgeom.h:65
int gbox_merge(const GBOX *new_box, GBOX *merge_box)
Update the merged GBOX to be large enough to include itself and the new box.
Definition: g_box.c:234
#define LW_FAILURE
Definition: liblwgeom.h:64
uint8_t flags
Definition: liblwgeom.h:488
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
LWGEOM ** geoms
Definition: liblwgeom.h:493
uint8_t flags
Definition: liblwgeom.h:275
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
Definition: g_box.c:648
Here is the call graph for this function:
Here is the caller graph for this function: