PostGIS  2.1.10dev-r@@SVN_REVISION@@
int gbox_overlaps ( const GBOX g1,
const GBOX g2 
)

Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.

Definition at line 241 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().

242 {
243 
244  /* Make sure our boxes are consistent */
246  lwerror("gbox_overlaps: cannot compare geodetic and non-geodetic boxes");
247 
248  /* Check X/Y first */
249  if ( g1->xmax < g2->xmin || g1->ymax < g2->ymin ||
250  g1->xmin > g2->xmax || g1->ymin > g2->ymax )
251  return LW_FALSE;
252 
253  /* Deal with the geodetic case special: we only compare the geodetic boxes (x/y/z) */
254  /* Never the M dimension */
256  {
257  if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
258  return LW_FALSE;
259  else
260  return LW_TRUE;
261  }
262 
263  /* If both geodetic or both have Z, check Z */
264  if ( FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags) )
265  {
266  if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
267  return LW_FALSE;
268  }
269 
270  /* If both have M, check M */
271  if ( FLAGS_GET_M(g1->flags) && FLAGS_GET_M(g2->flags) )
272  {
273  if ( g1->mmax < g2->mmin || g1->mmin > g2->mmax )
274  return LW_FALSE;
275  }
276 
277  return LW_TRUE;
278 }
#define FLAGS_GET_GEODETIC(flags)
Definition: liblwgeom.h:109
double xmax
Definition: liblwgeom.h:249
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
double zmax
Definition: liblwgeom.h:253
double ymin
Definition: liblwgeom.h:250
double xmin
Definition: liblwgeom.h:248
#define LW_FALSE
Definition: liblwgeom.h:52
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
double ymax
Definition: liblwgeom.h:251
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
uint8_t flags
Definition: liblwgeom.h:247
double mmin
Definition: liblwgeom.h:254
double zmin
Definition: liblwgeom.h:252
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
double mmax
Definition: liblwgeom.h:255

Here is the call graph for this function:

Here is the caller graph for this function: