PostGIS  2.4.9dev-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 295 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().

296 {
297 
298  /* Make sure our boxes are consistent */
300  lwerror("gbox_overlaps: cannot compare geodetic and non-geodetic boxes");
301 
302  /* Check X/Y first */
303  if ( g1->xmax < g2->xmin || g1->ymax < g2->ymin ||
304  g1->xmin > g2->xmax || g1->ymin > g2->ymax )
305  return LW_FALSE;
306 
307  /* Deal with the geodetic case special: we only compare the geodetic boxes (x/y/z) */
308  /* Never the M dimension */
310  {
311  if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
312  return LW_FALSE;
313  else
314  return LW_TRUE;
315  }
316 
317  /* If both geodetic or both have Z, check Z */
318  if ( FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags) )
319  {
320  if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
321  return LW_FALSE;
322  }
323 
324  /* If both have M, check M */
325  if ( FLAGS_GET_M(g1->flags) && FLAGS_GET_M(g2->flags) )
326  {
327  if ( g1->mmax < g2->mmin || g1->mmin > g2->mmax )
328  return LW_FALSE;
329  }
330 
331  return LW_TRUE;
332 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:143
double xmax
Definition: liblwgeom.h:293
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
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
uint8_t flags
Definition: liblwgeom.h:291
double mmin
Definition: liblwgeom.h:298
double zmin
Definition: liblwgeom.h:296
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
double mmax
Definition: liblwgeom.h:299
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: