PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwcollection_calculate_gbox_geodetic()

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

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

2592 {
2593  GBOX subbox;
2594  int i;
2595  int result = LW_FAILURE;
2596  int first = LW_TRUE;
2597  assert(coll);
2598  if ( coll->ngeoms == 0 )
2599  return LW_FAILURE;
2600 
2601  subbox.flags = gbox->flags;
2602 
2603  for ( i = 0; i < coll->ngeoms; i++ )
2604  {
2605  if ( lwgeom_calculate_gbox_geodetic((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
2606  {
2607  /* Keep a copy of the sub-bounding box for later */
2608  if ( coll->geoms[i]->bbox )
2609  lwfree(coll->geoms[i]->bbox);
2610  coll->geoms[i]->bbox = gbox_copy(&subbox);
2611  if ( first )
2612  {
2613  gbox_duplicate(&subbox, gbox);
2614  first = LW_FALSE;
2615  }
2616  else
2617  {
2618  gbox_merge(&subbox, gbox);
2619  }
2620  result = LW_SUCCESS;
2621  }
2622  }
2623  return result;
2624 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:438
GBOX * bbox
Definition: liblwgeom.h:397
void gbox_duplicate(const GBOX *original, GBOX *duplicate)
Copy the values of original GBOX into duplicate.
Definition: g_box.c:445
void lwfree(void *mem)
Definition: lwutil.c:242
#define LW_SUCCESS
Definition: liblwgeom.h:79
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:78
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
LWGEOM ** geoms
Definition: liblwgeom.h:508
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:2626
uint8_t flags
Definition: liblwgeom.h:290
Here is the call graph for this function:
Here is the caller graph for this function: