PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ gbox_union()

int gbox_union ( const GBOX g1,
const GBOX g2,
GBOX gout 
)

Update the output GBOX to be large enough to include both inputs.

Definition at line 146 of file g_box.c.

References GBOX::flags, FP_MAX, FP_MIN, LW_FALSE, LW_TRUE, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by BOX2D_union(), geography_bestsrid(), and lwt_ChangeEdgeGeom().

147 {
148  if ( ( ! g1 ) && ( ! g2 ) )
149  return LW_FALSE;
150 
151  if ( ! g1 )
152  {
153  memcpy(gout, g2, sizeof(GBOX));
154  return LW_TRUE;
155  }
156  if ( ! g2 )
157  {
158  memcpy(gout, g1, sizeof(GBOX));
159  return LW_TRUE;
160  }
161 
162  gout->flags = g1->flags;
163 
164  gout->xmin = FP_MIN(g1->xmin, g2->xmin);
165  gout->xmax = FP_MAX(g1->xmax, g2->xmax);
166 
167  gout->ymin = FP_MIN(g1->ymin, g2->ymin);
168  gout->ymax = FP_MAX(g1->ymax, g2->ymax);
169 
170  gout->zmin = FP_MIN(g1->zmin, g2->zmin);
171  gout->zmax = FP_MAX(g1->zmax, g2->zmax);
172 
173  return LW_TRUE;
174 }
double xmax
Definition: liblwgeom.h:292
#define FP_MIN(A, B)
double zmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:293
double xmin
Definition: liblwgeom.h:291
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
double ymax
Definition: liblwgeom.h:294
uint8_t flags
Definition: liblwgeom.h:290
double zmin
Definition: liblwgeom.h:295
#define FP_MAX(A, B)
Here is the caller graph for this function: