turf.intersect fails in 3.0.5
See original GitHub issueI have a jsfiddle example here of turf.intersect failing
If you click the button that says “Click me - I fail” and look in the developer tools console you will see:
Uncaught TypeError: this.seg.p1.equals2D is not a function
However, if I run a turf.simplify(polygon2, 0.00001, false)
as seen by clicking on the button that says “Click me - I work because Im simple” the intersect function is successful.
I dug down a bit and there appears to be multiple problems. It appears that the reason for the “equals2D is not a function” is because in the snapSegments an add function is called that is adding the index to the array as an element instead of the object that contains the coords and functions.
I went and fixed this in my code and tried again but, it just fails again because once again the snapSegments causes the creation of an invalid polygon.
I’ve had to do this all with the minified turfjs lib so I can’t tell you the line of code that the failure is on. I can’t seem to find a way of getting a non minified version. Most of the links in the documentation are wrong/broken or do not point to the latest version of turf.
This example works fine in turf 2.0.0 as seen on this jsFiddle example
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:15 (11 by maintainers)
Created a failing test case on requirebin using turf-union. Error in the console is the dreaded
Uncaught TypeError: this.seg.p1.equals2D is not a function
. The two features were very similar circular-ish polygons the cover most of the same area (but not exactly; they were generated by using a largeturf-buffer
on two nearby points, then I chopped verticles randomly until I got two much simpler polygons that still produce the error) cc: @anandthakkerOh that’s pretty ironic! No worries 👍 one line or multi line is fine.