Given a unit geocentric gbox, return a lon/lat (degrees) coordinate point point that is guaranteed to be outside the box (and therefore anything it contains).
Calculate a spherical point that falls outside the geocentric gbox.
Definition at line 1465 of file lwgeodetic.c.
References cart2geog(), gbox_contains_point3d(), GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, LWDEBUG, LWDEBUGF, lwerror(), normalize(), rad2deg, pixval::x, POINT2D::x, POINT3D::x, GBOX::xmax, GBOX::xmin, pixval::y, POINT2D::y, POINT3D::y, GBOX::ymax, GBOX::ymin, POINT3D::z, GBOX::zmax, and GBOX::zmin.
Referenced by CircTreePIP(), geography_point_outside(), lwpoly_covers_point2d(), lwpoly_pt_outside(), and test_tree_circ_pip2().
1467 double grow = M_PI / 180.0 / 60.0;
1474 while ( grow < M_PI )
1478 if ( ge.
xmin > -1 ) ge.
xmin -= grow;
1479 if ( ge.
ymin > -1 ) ge.
ymin -= grow;
1480 if ( ge.
zmin > -1 ) ge.
zmin -= grow;
1481 if ( ge.
xmax < 1 ) ge.
xmax += grow;
1482 if ( ge.
ymax < 1 ) ge.
ymax += grow;
1483 if ( ge.
zmax < 1 ) ge.
zmax += grow;
1486 corners[0].
x = ge.
xmin;
1487 corners[0].
y = ge.
ymin;
1488 corners[0].
z = ge.
zmin;
1490 corners[1].
x = ge.
xmin;
1491 corners[1].
y = ge.
ymax;
1492 corners[1].
z = ge.
zmin;
1494 corners[2].
x = ge.
xmin;
1495 corners[2].
y = ge.
ymin;
1496 corners[2].
z = ge.
zmax;
1498 corners[3].
x = ge.
xmax;
1499 corners[3].
y = ge.
ymin;
1500 corners[3].
z = ge.
zmin;
1502 corners[4].
x = ge.
xmax;
1503 corners[4].
y = ge.
ymax;
1504 corners[4].
z = ge.
zmin;
1506 corners[5].
x = ge.
xmax;
1507 corners[5].
y = ge.
ymin;
1508 corners[5].
z = ge.
zmax;
1510 corners[6].
x = ge.
xmin;
1511 corners[6].
y = ge.
ymax;
1512 corners[6].
z = ge.
zmax;
1514 corners[7].
x = ge.
xmax;
1515 corners[7].
y = ge.
ymax;
1516 corners[7].
z = ge.
zmax;
1518 LWDEBUG(4,
"trying to use a box corner point...");
1519 for ( i = 0; i < 8; i++ )
1522 LWDEBUGF(4,
"testing corner %d: POINT(%.8g %.8g %.8g)", i, corners[i].
x, corners[i].
y, corners[i].z);
1525 LWDEBUGF(4,
"corner %d is outside our gbox", i);
1531 LWDEBUGF(4,
"returning POINT(%.8g %.8g) as outside point", pt_outside->
x, pt_outside->
y);
1541 lwerror(
"BOOM! Could not generate outside point!");
void normalize(POINT3D *p)
Normalize to a unit vector.
int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Convert cartesian coordinates on unit sphere to spherical coordinates.
#define LWDEBUG(level, msg)
Point in spherical coordinates on the world.
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.