PostGIS  2.5.7dev-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 290 of file g_box.c.

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

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().

Here is the call graph for this function:
Here is the caller graph for this function: