819{
820 int wn = 0;
821 uint32_t i;
822 double side;
825
826 POSTGIS_DEBUG(2, "point_in_ring called.");
827
829 for (i=0; i<pts->
npoints-1; i++)
830 {
831 seg1 = seg2;
833
835
836 POSTGIS_DEBUGF(3,
"segment: (%.8f, %.8f),(%.8f, %.8f)", seg1->
x, seg1->
y, seg2->
x, seg2->
y);
837 POSTGIS_DEBUGF(3, "side result: %.8f", side);
839
840
841 if ((seg2->
x == seg1->
x) && (seg2->
y == seg1->
y))
842 {
843 POSTGIS_DEBUG(3, "segment is zero length... ignoring.");
844
845 continue;
846 }
847
848
849
850 if (side == 0.0)
851 {
853 {
854 POSTGIS_DEBUGF(3, "point on ring boundary between points %d, %d", i, i+1);
855
856 return 0;
857 }
858 }
859
860
861
862
863
864
865 if ((seg1->
y <= point->
y) && (point->
y < seg2->
y) && (side > 0))
866 {
867 POSTGIS_DEBUG(3, "incrementing winding number.");
868
869 ++wn;
870 }
871
872
873
874
875
876 else if ((seg2->
y <= point->
y) && (point->
y < seg1->
y) && (side < 0))
877 {
878 POSTGIS_DEBUG(3, "decrementing winding number.");
879
880 --wn;
881 }
882 }
883
884 POSTGIS_DEBUGF(3, "winding number %d", wn);
885
886 if (wn == 0)
887 return -1;
888 return 1;
889}
#define FP_CONTAINS_BOTTOM(A, X, B)
static int isOnSegment(const POINT2D *seg1, const POINT2D *seg2, const POINT2D *point)
static double determineSide(const POINT2D *seg1, const POINT2D *seg2, const POINT2D *point)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.