turf: turf.intersect fails in 3.0.5
I 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
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 15 (11 by maintainers)
Commits related to this issue
- Add formerly failing test case from issue #412 — committed to developmentseed/turf by drewbo 7 years ago
- Add formerly failing test case for turf-intersect from issue #412 (#605) * Add formerly failing test case from issue #412 * Add expected output for test fixture — committed to Turfjs/turf by drewbo 7 years ago
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-bufferon two nearby points, then I chopped verticles randomly until I got two much simpler polygons that still produce the error) cc: @anandthakker