PostGIS  2.5.0dev-r@@SVN_REVISION@@
static int lwcollection_calculate_gbox_geodetic ( const LWCOLLECTION coll,
GBOX gbox 
)
static

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

2893 {
2894  GBOX subbox;
2895  uint32_t i;
2896  int result = LW_FAILURE;
2897  int first = LW_TRUE;
2898  assert(coll);
2899  if ( coll->ngeoms == 0 )
2900  return LW_FAILURE;
2901 
2902  subbox.flags = gbox->flags;
2903 
2904  for ( i = 0; i < coll->ngeoms; i++ )
2905  {
2906  if ( lwgeom_calculate_gbox_geodetic((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
2907  {
2908  /* Keep a copy of the sub-bounding box for later */
2909  if ( coll->geoms[i]->bbox )
2910  lwfree(coll->geoms[i]->bbox);
2911  coll->geoms[i]->bbox = gbox_copy(&subbox);
2912  if ( first )
2913  {
2914  gbox_duplicate(&subbox, gbox);
2915  first = LW_FALSE;
2916  }
2917  else
2918  {
2919  gbox_merge(&subbox, gbox);
2920  }
2921  result = LW_SUCCESS;
2922  }
2923  }
2924  return result;
2925 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:433
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:440
void lwfree(void *mem)
Definition: lwutil.c:244
#define LW_SUCCESS
Definition: liblwgeom.h:79
uint32_t ngeoms
Definition: liblwgeom.h:506
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:264
#define LW_FAILURE
Definition: liblwgeom.h:78
unsigned int uint32_t
Definition: uthash.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:2927
uint8_t flags
Definition: liblwgeom.h:290

Here is the call graph for this function:

Here is the caller graph for this function: