PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcollection_calculate_gbox_geodetic()

static int lwcollection_calculate_gbox_geodetic ( const LWCOLLECTION coll,
GBOX gbox 
)
static

Definition at line 2580 of file lwgeodetic.c.

References LWGEOM::bbox, GBOX::flags, gbox_copy(), gbox_duplicate(), gbox_merge(), LWCOLLECTION::geoms, LW_FAILURE, LW_FALSE, LW_SUCCESS, LW_TRUE, lwfree(), lwgeom_calculate_gbox_geodetic(), and LWCOLLECTION::ngeoms.

Referenced by lwgeom_calculate_gbox_geodetic().

2581 {
2582  GBOX subbox;
2583  int i;
2584  int result = LW_FAILURE;
2585  int first = LW_TRUE;
2586  assert(coll);
2587  if ( coll->ngeoms == 0 )
2588  return LW_FAILURE;
2589 
2590  subbox.flags = gbox->flags;
2591 
2592  for ( i = 0; i < coll->ngeoms; i++ )
2593  {
2594  if ( lwgeom_calculate_gbox_geodetic((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
2595  {
2596  /* Keep a copy of the sub-bounding box for later */
2597  if ( coll->geoms[i]->bbox )
2598  lwfree(coll->geoms[i]->bbox);
2599  coll->geoms[i]->bbox = gbox_copy(&subbox);
2600  if ( first )
2601  {
2602  gbox_duplicate(&subbox, gbox);
2603  first = LW_FALSE;
2604  }
2605  else
2606  {
2607  gbox_merge(&subbox, gbox);
2608  }
2609  result = LW_SUCCESS;
2610  }
2611  }
2612  return result;
2613 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:403
GBOX * bbox
Definition: liblwgeom.h:382
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
Definition: g_box.c:410
void lwfree(void *mem)
Definition: lwutil.c:214
#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
#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
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:2615
uint8_t flags
Definition: liblwgeom.h:275
Here is the call graph for this function:
Here is the caller graph for this function: