PostGIS  2.2.8dev-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 234 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().

235 {
236  assert(merge_box);
237 
238  if ( FLAGS_GET_ZM(merge_box->flags) != FLAGS_GET_ZM(new_box->flags) )
239  return LW_FAILURE;
240 
241  if ( new_box->xmin < merge_box->xmin) merge_box->xmin = new_box->xmin;
242  if ( new_box->ymin < merge_box->ymin) merge_box->ymin = new_box->ymin;
243  if ( new_box->xmax > merge_box->xmax) merge_box->xmax = new_box->xmax;
244  if ( new_box->ymax > merge_box->ymax) merge_box->ymax = new_box->ymax;
245 
246  if ( FLAGS_GET_Z(merge_box->flags) || FLAGS_GET_GEODETIC(merge_box->flags) )
247  {
248  if ( new_box->zmin < merge_box->zmin) merge_box->zmin = new_box->zmin;
249  if ( new_box->zmax > merge_box->zmax) merge_box->zmax = new_box->zmax;
250  }
251  if ( FLAGS_GET_M(merge_box->flags) )
252  {
253  if ( new_box->mmin < merge_box->mmin) merge_box->mmin = new_box->mmin;
254  if ( new_box->mmax > merge_box->mmax) merge_box->mmax = new_box->mmax;
255  }
256 
257  return LW_SUCCESS;
258 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:127
double xmax
Definition: liblwgeom.h:277
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:137
#define LW_FAILURE
Definition: liblwgeom.h:64
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
double xmin
Definition: liblwgeom.h:276
double ymax
Definition: liblwgeom.h:279
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
uint8_t flags
Definition: liblwgeom.h:275
double mmin
Definition: liblwgeom.h:282
double zmin
Definition: liblwgeom.h:280
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
double mmax
Definition: liblwgeom.h:283
Here is the caller graph for this function: