PostGIS  2.4.9dev-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:293
#define FP_MIN(A, B)
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
double ymax
Definition: liblwgeom.h:295
uint8_t flags
Definition: liblwgeom.h:291
double zmin
Definition: liblwgeom.h:296
#define FP_MAX(A, B)
Here is the caller graph for this function: