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 3502 of file lwgeodetic.c.
3503{
3507 uint32_t
count = 0, i, inter;
3508
3509
3510 if ( ! pa || pa->
npoints < 4 )
3512
3513
3516
3517
3520
3521
3522 for ( i = 1; i < pa->
npoints; i++ )
3523 {
3524 LWDEBUGF(4,
"testing edge (%d)", i);
3525 LWDEBUGF(4,
" start point == POINT(%.12g %.12g)", p.
x, p.
y);
3526
3527
3530
3531
3533 {
3534 continue;
3535 }
3536
3537
3539 {
3541 }
3542
3543
3545
3546
3548 {
3549
3550
3552 {
3554 }
3555
3556
3557
3559 {
3560
3561 LWDEBUGF(4,
" edge (%d) crossed, count == %d, disregarding to avoid double count", i, count);
3562 }
3563 else
3564 {
3565
3567 LWDEBUGF(4,
" edge (%d) crossed, count == %d", i, count);
3568 }
3569 }
3570 else
3571 {
3572 LWDEBUGF(4,
" edge (%d) did not cross", i);
3573 }
3574
3575
3576 E1 = E2;
3577 }
3578
3579 LWDEBUGF(4,
"final count == %d", count);
3580
3581
3582 if ( count % 2 )
3583 {
3585 }
3586
3588}
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().