Found out about this algorithm in another project and it seems nice so I propose to replace the old one.
Why? Is it faster?
Is is slightly faster in some cases and as fast in all cases according to the author. It can also handle non simple polygons.
Interesting! I think your latter point is even more important: for polygons with self-intersections the currently used Crossing Number algorithm will give wrong answers in the parts where the polygon overlaps with itself an even number of times. The Winding Number algorithm does not have this problem.
hey @bjornharrtell, any chance of adding tests for non simple polygons?
You got it @marcjansen. :)
Thanks for adding the tests, @bjornharrtell. Is it just me or are these tests passing with or without changing the algorithm?
I still think this looks good, but just want to confirm.
Add test case for ol.geom.flat.contains
Use winding number algorithm for linearRingContainsXY
The test returns true for point inside an overlap of a non-simple polygon should fail with the existing algorithm. I just cherry picked d344098 on master and it fails as expected. Though I noticed that I had forgot to change the description of the test cases, I've fixed that now.
returns true for point inside an overlap of a non-simple polygon
Thanks for this @bjornharrtell.