828{
829
831 lwerror(
"%s called on invalid linestring", __func__);
832
833 int intersections = 0;
836
837
838 for (uint32_t i = 0; i < pa->
npoints-1; ++i)
839 {
842
843
845 continue;
846
847
849 {
851 return 0;
852 }
853
854
855
856
857
858
859
860
861
862 if (((p1->
y <= py) && (py < p2->y)) || ((p2->
y <= py) && (py < p1->y)))
863 {
864
865
866
867
868 double x_intersection = p1->
x + (py - p1->
y) * (p2->
x - p1->
x) / (p2->
y - p1->
y);
869
870
871
872
873
874 if (x_intersection > px)
875 {
876 intersections++;
877 }
878 }
879 }
880
881 return intersections;
882}
#define LW_TRUE
Return types for functions with status returns.
int lw_pt_on_segment(const POINT2D *p1, const POINT2D *p2, const POINT2D *p)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.