PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gbox_overlaps()

int gbox_overlaps ( const GBOX g1,
const GBOX g2 
)

Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.

Definition at line 260 of file g_box.c.

References GBOX::flags, FLAGS_GET_GEODETIC, FLAGS_GET_M, FLAGS_GET_Z, LW_FALSE, LW_TRUE, lwerror(), GBOX::mmax, GBOX::mmin, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by lwgeom_distance_spheroid().

261 {
262 
263  /* Make sure our boxes are consistent */
265  lwerror("gbox_overlaps: cannot compare geodetic and non-geodetic boxes");
266 
267  /* Check X/Y first */
268  if ( g1->xmax < g2->xmin || g1->ymax < g2->ymin ||
269  g1->xmin > g2->xmax || g1->ymin > g2->ymax )
270  return LW_FALSE;
271 
272  /* Deal with the geodetic case special: we only compare the geodetic boxes (x/y/z) */
273  /* Never the M dimension */
275  {
276  if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
277  return LW_FALSE;
278  else
279  return LW_TRUE;
280  }
281 
282  /* If both geodetic or both have Z, check Z */
283  if ( FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags) )
284  {
285  if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
286  return LW_FALSE;
287  }
288 
289  /* If both have M, check M */
290  if ( FLAGS_GET_M(g1->flags) && FLAGS_GET_M(g2->flags) )
291  {
292  if ( g1->mmax < g2->mmin || g1->mmin > g2->mmax )
293  return LW_FALSE;
294  }
295 
296  return LW_TRUE;
297 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:127
double xmax
Definition: liblwgeom.h:277
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
double xmin
Definition: liblwgeom.h:276
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
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
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: