Given a polygon (lon/lat decimal degrees) and point (lon/lat decimal degrees) and a guaranteed outside point (lon/lat decimal degrees) (calculate with gbox_pt_outside()) return LW_TRUE if point is inside or on edge of polygon.
2521 int in_hole_count = 0;
2526 #if POSTGIS_DEBUG_LEVEL >= 4
2534 LWDEBUG(4,
"returning false, geometry is empty or null");
2540 gbox = *(poly->
bbox);
2549 LWDEBUG(4,
"the point is not in the box!");
2556 LWDEBUGF(4,
"pt_outside POINT(%.18g %.18g)", pt_outside.
x, pt_outside.
y);
2557 LWDEBUGF(4,
"pt_to_test POINT(%.18g %.18g)", pt_to_test->
x, pt_to_test->
y);
2558 #if POSTGIS_DEBUG_LEVEL >= 4
2560 LWDEBUGF(4,
"polygon %s", geom_ewkt);
2570 LWDEBUG(4,
"returning false, point is outside ring");
2574 LWDEBUGF(4,
"testing %d rings", poly->nrings);
2577 for ( i = 1; i < poly->nrings; i++ )
2579 LWDEBUGF(4,
"ring test loop %d", i);
2585 LWDEBUGF(4,
"in_hole_count == %d", in_hole_count);
2587 if ( in_hole_count % 2 )
2589 LWDEBUG(4,
"returning false, inner ring containment count is odd");
2593 LWDEBUG(4,
"returning true, inner ring containment count is even");
int gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
#define LW_TRUE
Return types for functions with status returns.
int ptarray_contains_point_sphere(const POINTARRAY *pa, const POINT2D *pt_outside, const POINT2D *pt_to_test)
This routine returns LW_TRUE if the stabline joining the pt_outside and pt_to_test crosses the ring a...
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
int lwpoly_pt_outside(const LWPOLY *poly, POINT2D *pt_outside)
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesian coordinates on unit sphere.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
Point in spherical coordinates on the world.