question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

turf.intersect fails in 3.0.5

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
drewbocommented, Aug 25, 2016

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 large turf-buffer on two nearby points, then I chopped verticles randomly until I got two much simpler polygons that still produce the error) cc: @anandthakker

0reactions
DenisCarrierecommented, Mar 7, 2017

Oh that’s pretty ironic! No worries 👍 one line or multi line is fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

turf.js intersect problem? - leaflet
I cerate a loop for every feature in "polygon" feature collection and calculate intersections using turf.js but I receive an error "geojson ...
Read more >
turf.js Intersect Error for Self-intersecting Polygons from ...
js intersect() function fails with the following error (Line 326 is where I call intersect() ). turf.min.js:9 Uncaught [object Object]
Read more >
Turf.js | Advanced geospatial analysis
Takes two polygon or multi-polygon geometries and finds their polygonal intersection. If they don't intersect, returns null.
Read more >
How to use the turf.intersect function in turf
To help you get started, we've selected a few turf.intersect examples, based on popular ways it is used in public projects.
Read more >
GeoJSONKitTurf
A fork of turf-swift based on GeoJSONKit ... GeoJSONKitTurf requires Xcode 12.x and supports the following minimum ... turf-line-intersect, GeoJSON.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found