PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gbox_overlaps()

int gbox_overlaps ( const GBOX g1,
const GBOX g2 
)

Return LW_TRUE if the GBOX overlaps, LW_FALSE otherwise.

Definition at line 283 of file gbox.c.

284{
285
286 /* Make sure our boxes are consistent */
288 lwerror("gbox_overlaps: cannot compare geodetic and non-geodetic boxes");
289
290 /* Check X/Y first */
291 if ( g1->xmax < g2->xmin || g1->ymax < g2->ymin ||
292 g1->xmin > g2->xmax || g1->ymin > g2->ymax )
293 return LW_FALSE;
294
295 /* Deal with the geodetic case special: we only compare the geodetic boxes (x/y/z) */
296 /* Never the M dimension */
298 {
299 if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
300 return LW_FALSE;
301 else
302 return LW_TRUE;
303 }
304
305 /* If both geodetic or both have Z, check Z */
306 if ( FLAGS_GET_Z(g1->flags) && FLAGS_GET_Z(g2->flags) )
307 {
308 if ( g1->zmax < g2->zmin || g1->zmin > g2->zmax )
309 return LW_FALSE;
310 }
311
312 /* If both have M, check M */
313 if ( FLAGS_GET_M(g1->flags) && FLAGS_GET_M(g2->flags) )
314 {
315 if ( g1->mmax < g2->mmin || g1->mmin > g2->mmax )
316 return LW_FALSE;
317 }
318
319 return LW_TRUE;
320}
#define LW_FALSE
Definition liblwgeom.h:94
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
#define FLAGS_GET_GEODETIC(flags)
Definition liblwgeom.h:168
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
double ymax
Definition liblwgeom.h:357
double zmax
Definition liblwgeom.h:359
double xmax
Definition liblwgeom.h:355
double zmin
Definition liblwgeom.h:358
double mmax
Definition liblwgeom.h:361
double ymin
Definition liblwgeom.h:356
double xmin
Definition liblwgeom.h:354
double mmin
Definition liblwgeom.h:360
lwflags_t flags
Definition liblwgeom.h:353

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: