Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript

Home Page:https://turfjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

buffer() is returning overnested geometry coordinates after buffering.

MelvinNumerisk opened this issue · comments

commented

Hi,

Context

I'm facing a pretty unexpected issue by using buffer() method from v6.5.0 of TurfJS, I have a geojson which is a very massive multiPolygon, and to avoid a freezing app, I'm transforming each multiPolygon's coordinates arrays to independent polygon before buffering them and then, reconstruct a multiPolygon by getting all the buffered polygons coordinates.

Problem

But unexpectly, after buffering one of the coordinates, the buffer method isn't returning the expected coordinates format (expected : number[][], found : number[][][]), it seem overneasting the coordinates who made it as not a valid geometry for polygons or multiPolygons later when I will re-use it using union() to uniformize my geojson.

Reproduce

Feel free to see what is happening in this JsFiddle.

I'm having a little trouble following the fiddle. Can you simplify it to a single call to buffer() with a single input, that produces an unexpected output? There's a chance the issue might lie in the looping/array building you're doing outside of buffer.