PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwcollection_calculate_gbox_geodetic()

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

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

2906 {
2907  GBOX subbox;
2908  uint32_t i;
2909  int result = LW_FAILURE;
2910  int first = LW_TRUE;
2911  assert(coll);
2912  if ( coll->ngeoms == 0 )
2913  return LW_FAILURE;
2914 
2915  subbox.flags = gbox->flags;
2916 
2917  for ( i = 0; i < coll->ngeoms; i++ )
2918  {
2919  if ( lwgeom_calculate_gbox_geodetic((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
2920  {
2921  /* Keep a copy of the sub-bounding box for later */
2922  if ( coll->geoms[i]->bbox )
2923  lwfree(coll->geoms[i]->bbox);
2924  coll->geoms[i]->bbox = gbox_copy(&subbox);
2925  if ( first )
2926  {
2927  gbox_duplicate(&subbox, gbox);
2928  first = LW_FALSE;
2929  }
2930  else
2931  {
2932  gbox_merge(&subbox, gbox);
2933  }
2934  result = LW_SUCCESS;
2935  }
2936  }
2937  return result;
2938 }
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:400
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:509
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:511
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:2940
uint8_t flags
Definition: liblwgeom.h:293
Here is the call graph for this function:
Here is the caller graph for this function: