PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcollection_calculate_gbox_geodetic()

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

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

2978 {
2979  GBOX subbox;
2980  int i;
2981  int result = LW_FAILURE;
2982  int first = LW_TRUE;
2983  assert(coll);
2984  if ( coll->ngeoms == 0 )
2985  return LW_FAILURE;
2986 
2987  subbox.flags = gbox->flags;
2988 
2989  for ( i = 0; i < coll->ngeoms; i++ )
2990  {
2991  if ( lwgeom_calculate_gbox_geodetic((LWGEOM*)(coll->geoms[i]), &subbox) == LW_SUCCESS )
2992  {
2993  /* Keep a copy of the sub-bounding box for later */
2994  if ( coll->geoms[i]->bbox )
2995  lwfree(coll->geoms[i]->bbox);
2996  coll->geoms[i]->bbox = gbox_copy(&subbox);
2997  if ( first )
2998  {
2999  gbox_duplicate(&subbox, gbox);
3000  first = LW_FALSE;
3001  }
3002  else
3003  {
3004  gbox_merge(&subbox, gbox);
3005  }
3006  result = LW_SUCCESS;
3007  }
3008  }
3009  return result;
3010 }
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:398
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:244
#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
#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
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
Definition: lwgeodetic.c:3012
uint8_t flags
Definition: liblwgeom.h:291
Here is the call graph for this function:
Here is the caller graph for this function: