-
Notifications
You must be signed in to change notification settings - Fork 994
Description
- The version of Turf using: 6.5.0
I am using a 3rd party API to get geometry data based on a bounding box and that data consists of multi polygons with rings having hundreds of coordinates. Everything works fine in such cases, I recently came across an example where API response had multi polygon with 1 or 2 rings having 150k+ coordinates (geometry feature of some river or a forest) and that feature had 1000+ rings.
Taking intersection of that multi polygon with my site polygon using turf.intersect(incomingFeature, sitePolygon) gets stuck and never complete its execution.
What I have done for now:
I have split incoming feature rings in two separate multi polygons, one with rings having coordinates greater than 10k and the other one with rings having coordinates less than 10k. turf.intersect seems to be working fine in this way, which seems weird. Why can't it process the multipolygon without splitting the rings ?
//Code snippet
//make polygon from incoming features
let incomingMultiPolygon = returnedFeatures[i].geometry.rings.filter(x => x.length <= 10000);
if (incomingMultiPolygon.length > 0)
this.checkIntersection(incomingMultiPolygon, siteBoundary);
incomingMultiPolygon = returnedFeatures[i].geometry.rings.filter(x => x.length > 10000);
if (incomingMultiPolygon.length > 0)
this.checkIntersection(incomingMultiPolygon, siteBoundary);
//this.checkIntersection calls turf.intersect(incomingMultiPolygon, siteBoundary) and do something with the result.