PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ gbox_merge()

int gbox_merge ( const GBOX new_box,
GBOX merged_box 
)

Update the merged GBOX to be large enough to include itself and the new box.

Definition at line 269 of file g_box.c.

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_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().

270 {
271  assert(merge_box);
272 
273  if ( FLAGS_GET_ZM(merge_box->flags) != FLAGS_GET_ZM(new_box->flags) )
274  return LW_FAILURE;
275 
276  if ( new_box->xmin < merge_box->xmin) merge_box->xmin = new_box->xmin;
277  if ( new_box->ymin < merge_box->ymin) merge_box->ymin = new_box->ymin;
278  if ( new_box->xmax > merge_box->xmax) merge_box->xmax = new_box->xmax;
279  if ( new_box->ymax > merge_box->ymax) merge_box->ymax = new_box->ymax;
280 
281  if ( FLAGS_GET_Z(merge_box->flags) || FLAGS_GET_GEODETIC(merge_box->flags) )
282  {
283  if ( new_box->zmin < merge_box->zmin) merge_box->zmin = new_box->zmin;
284  if ( new_box->zmax > merge_box->zmax) merge_box->zmax = new_box->zmax;
285  }
286  if ( FLAGS_GET_M(merge_box->flags) )
287  {
288  if ( new_box->mmin < merge_box->mmin) merge_box->mmin = new_box->mmin;
289  if ( new_box->mmax > merge_box->mmax) merge_box->mmax = new_box->mmax;
290  }
291 
292  return LW_SUCCESS;
293 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:143
double xmax
Definition: liblwgeom.h:293
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:153
#define LW_FAILURE
Definition: liblwgeom.h:79
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
double ymax
Definition: liblwgeom.h:295
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
uint8_t flags
Definition: liblwgeom.h:291
double mmin
Definition: liblwgeom.h:298
double zmin
Definition: liblwgeom.h:296
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
double mmax
Definition: liblwgeom.h:299
Here is the caller graph for this function: