PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcollection_calculate_gbox_cartesian()

static int lwcollection_calculate_gbox_cartesian ( LWCOLLECTION coll,
GBOX gbox 
)
static

Definition at line 648 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().

649 {
650  GBOX subbox;
651  int i;
652  int result = LW_FAILURE;
653  int first = LW_TRUE;
654  assert(coll);
655  if ( (coll->ngeoms == 0) || !gbox)
656  return LW_FAILURE;
657 
658  subbox.flags = coll->flags;
659 
660  for ( i = 0; i < coll->ngeoms; i++ )
661  {
662  if ( lwgeom_calculate_gbox_cartesian((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
663  {
664  /* Keep a copy of the sub-bounding box for later
665  if ( coll->geoms[i]->bbox )
666  lwfree(coll->geoms[i]->bbox);
667  coll->geoms[i]->bbox = gbox_copy(&subbox); */
668  if ( first )
669  {
670  gbox_duplicate(&subbox, gbox);
671  first = LW_FALSE;
672  }
673  else
674  {
675  gbox_merge(&subbox, gbox);
676  }
677  result = LW_SUCCESS;
678  }
679  }
680  return result;
681 }
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
Definition: g_box.c:445
#define LW_SUCCESS
Definition: liblwgeom.h:80
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:269
#define LW_FAILURE
Definition: liblwgeom.h:79
uint8_t flags
Definition: liblwgeom.h:504
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWGEOM ** geoms
Definition: liblwgeom.h:509
uint8_t flags
Definition: liblwgeom.h:291
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
Definition: g_box.c:683
Here is the call graph for this function:
Here is the caller graph for this function: