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.
2513 int in_hole_count = 0;
2523 LWDEBUG(4,
"returning false, geometry is empty or null");
2529 gbox = *(poly->
bbox);
2538 LWDEBUG(4,
"the point is not in the box!");
2545 LWDEBUGF(4,
"pt_outside POINT(%.18g %.18g)", pt_outside.
x, pt_outside.
y);
2546 LWDEBUGF(4,
"pt_to_test POINT(%.18g %.18g)", pt_to_test->
x, pt_to_test->
y);
2553 LWDEBUG(4,
"returning false, point is outside ring");
2557 LWDEBUGF(4,
"testing %d rings", poly->nrings);
2560 for ( i = 1; i < poly->nrings; i++ )
2562 LWDEBUGF(4,
"ring test loop %d", i);
2568 LWDEBUGF(4,
"in_hole_count == %d", in_hole_count);
2570 if ( in_hole_count % 2 )
2572 LWDEBUG(4,
"returning false, inner ring containment count is odd");
2576 LWDEBUG(4,
"returning true, inner ring containment count is even");
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 gbox_contains_point3d(const GBOX *gbox, const POINT3D *pt)
Return true if the point is inside the gbox.
#define LWDEBUG(level, msg)
Point in spherical coordinates on the world.
int lwpoly_pt_outside(const LWPOLY *poly, POINT2D *pt_outside)
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...
#define LW_TRUE
Return types for functions with status returns.
int lwgeom_calculate_gbox_geodetic(const LWGEOM *geom, GBOX *gbox)
Calculate the geodetic bounding box for an LWGEOM.
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesion coordinates on unit sphere.
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
#define LWDEBUGF(level, msg,...)