PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 215 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 lwcircstring_calculate_gbox_cartesian(), lwcollection_calculate_gbox_cartesian(), lwcollection_calculate_gbox_geodetic(), lwpolygon_calculate_gbox_geodetic(), and ptarray_calculate_gbox_geodetic().

216 {
217  assert(merge_box);
218 
219  if ( FLAGS_GET_ZM(merge_box->flags) != FLAGS_GET_ZM(new_box->flags) )
220  return LW_FAILURE;
221 
222  if ( new_box->xmin < merge_box->xmin) merge_box->xmin = new_box->xmin;
223  if ( new_box->ymin < merge_box->ymin) merge_box->ymin = new_box->ymin;
224  if ( new_box->xmax > merge_box->xmax) merge_box->xmax = new_box->xmax;
225  if ( new_box->ymax > merge_box->ymax) merge_box->ymax = new_box->ymax;
226 
227  if ( FLAGS_GET_Z(merge_box->flags) || FLAGS_GET_GEODETIC(merge_box->flags) )
228  {
229  if ( new_box->zmin < merge_box->zmin) merge_box->zmin = new_box->zmin;
230  if ( new_box->zmax > merge_box->zmax) merge_box->zmax = new_box->zmax;
231  }
232  if ( FLAGS_GET_M(merge_box->flags) )
233  {
234  if ( new_box->mmin < merge_box->mmin) merge_box->mmin = new_box->mmin;
235  if ( new_box->mmax > merge_box->mmax) merge_box->mmax = new_box->mmax;
236  }
237 
238  return LW_SUCCESS;
239 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:109
double xmax
Definition: liblwgeom.h:249
#define LW_SUCCESS
Definition: liblwgeom.h:55
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:119
#define LW_FAILURE
Definition: liblwgeom.h:54
double zmax
Definition: liblwgeom.h:253
double ymin
Definition: liblwgeom.h:250
double xmin
Definition: liblwgeom.h:248
double ymax
Definition: liblwgeom.h:251
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
uint8_t flags
Definition: liblwgeom.h:247
double mmin
Definition: liblwgeom.h:254
double zmin
Definition: liblwgeom.h:252
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
double mmax
Definition: liblwgeom.h:255

Here is the caller graph for this function: