This routine returns LW_TRUE if the stabline joining the pt_outside and pt_to_test crosses the ring an odd number of times, or if the pt_to_test is on the ring boundary itself, returning LW_FALSE otherwise.
The pt_outside must be guaranteed to be outside the ring (use the geography_pt_outside() function to derive one in postgis, or the gbox_pt_outside() function if you don't mind burning CPU cycles building a gbox first).
Definition at line 3647 of file lwgeodetic.c.
3648{
3652 uint32_t
count = 0, i, inter;
3653
3654
3655 if ( ! pa || pa->
npoints < 4 )
3657
3658
3661
3662
3665
3666
3667 for ( i = 1; i < pa->
npoints; i++ )
3668 {
3669 LWDEBUGF(4,
"testing edge (%d)", i);
3670 LWDEBUGF(4,
" start point == POINT(%.12g %.12g)", p.
x, p.
y);
3671
3672
3675
3676
3678 {
3679 continue;
3680 }
3681
3682
3684 {
3686 }
3687
3688
3690
3691
3693 {
3694
3695
3697 {
3699 }
3700
3701
3702
3704 {
3705
3706 LWDEBUGF(4,
" edge (%d) crossed, disregarding to avoid double count", i, count);
3707 }
3708 else
3709 {
3710
3712 LWDEBUGF(4,
" edge (%d) crossed, count == %d", i, count);
3713 }
3714 }
3715 else
3716 {
3717 LWDEBUGF(4,
" edge (%d) did not cross", i);
3718 }
3719
3720
3721 E1 = E2;
3722 }
3723
3724 LWDEBUGF(4,
"final count == %d", count);
3725
3726
3727 if ( count % 2 )
3728 {
3730 }
3731
3733}
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
#define LW_TRUE
Return types for functions with status returns.
void ll2cart(const POINT2D *g, POINT3D *p)
Convert lon/lat coordinates to cartesian coordinates on unit sphere.
uint32_t edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
Returns non-zero if edges A and B interact.
static int point3d_equals(const POINT3D *p1, const POINT3D *p2)
Utility function for ptarray_contains_point_sphere()
#define PIR_A_TOUCH_RIGHT
#define PIR_B_TOUCH_RIGHT
#define LWDEBUGF(level, msg,...)
References edge_intersects(), getPoint2d_p(), ll2cart(), LW_FALSE, LW_TRUE, LWDEBUGF, POINTARRAY::npoints, PIR_A_TOUCH_LEFT, PIR_A_TOUCH_RIGHT, PIR_B_TOUCH_RIGHT, PIR_COLINEAR, PIR_INTERSECTS, point3d_equals(), POINT2D::x, and POINT2D::y.
Referenced by lwpoly_covers_point2d(), test_ptarray_contains_point_sphere(), and test_ptarray_contains_point_sphere_iowa().