PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ gbox_merge()

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 at line 264 of file g_box.c.

265 {
266  assert(merge_box);
267 
268  if ( FLAGS_GET_ZM(merge_box->flags) != FLAGS_GET_ZM(new_box->flags) )
269  return LW_FAILURE;
270 
271  if ( new_box->xmin < merge_box->xmin) merge_box->xmin = new_box->xmin;
272  if ( new_box->ymin < merge_box->ymin) merge_box->ymin = new_box->ymin;
273  if ( new_box->xmax > merge_box->xmax) merge_box->xmax = new_box->xmax;
274  if ( new_box->ymax > merge_box->ymax) merge_box->ymax = new_box->ymax;
275 
276  if ( FLAGS_GET_Z(merge_box->flags) || FLAGS_GET_GEODETIC(merge_box->flags) )
277  {
278  if ( new_box->zmin < merge_box->zmin) merge_box->zmin = new_box->zmin;
279  if ( new_box->zmax > merge_box->zmax) merge_box->zmax = new_box->zmax;
280  }
281  if ( FLAGS_GET_M(merge_box->flags) )
282  {
283  if ( new_box->mmin < merge_box->mmin) merge_box->mmin = new_box->mmin;
284  if ( new_box->mmax > merge_box->mmax) merge_box->mmax = new_box->mmax;
285  }
286 
287  return LW_SUCCESS;
288 }
#define LW_FAILURE
Definition: liblwgeom.h:79
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:143
double ymax
Definition: liblwgeom.h:298
double zmax
Definition: liblwgeom.h:300
double xmax
Definition: liblwgeom.h:296
double zmin
Definition: liblwgeom.h:299
double mmax
Definition: liblwgeom.h:302
double ymin
Definition: liblwgeom.h:297
double xmin
Definition: liblwgeom.h:295
double mmin
Definition: liblwgeom.h:301
uint8_t flags
Definition: liblwgeom.h:294

References GBOX::flags, FLAGS_GET_GEODETIC, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_GET_ZM, LW_FAILURE, LW_SUCCESS, GBOX::mmax, GBOX::mmin, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by _lwt_EdgeRingGetBbox(), _lwt_RemEdge(), lwcircstring_calculate_gbox_cartesian(), lwcollection_calculate_gbox_cartesian(), lwcollection_calculate_gbox_geodetic(), LWGEOM_collect_garray(), lwpolygon_calculate_gbox_geodetic(), and ptarray_calculate_gbox_geodetic().

Here is the caller graph for this function: