Closed matthias-ccri closed 3 weeks ago
Hi @matthias-ccri
I believe this is resolved with the v7 alpha release - see this jsfiddle
The v7 alpha is available via npm npm install turf@7.0.0-alpha.1
or via cdn https://unpkg.com/turf@7.0.0-alpha.1/dist/turf.min.js
It's an alpha release so there are few things not quite right but it also fixes a number of bugs
Cheers Rowan
Thanks Rowan, the v7 buffering looks to be accurate! I can't wait for v7 to land.
I only tested in the northern hemisphere. Surely the southern hemisphere also has the same distortion problems, but the transverseMercator mode only kicks in for shapes > 50 lat. I wonder, why not use the transverseMercator method in all cases?
The transverseMercator method (reprojecting to Transverse Mercator and centering on the shape) seems like the most accurate option so far. Is it being avoided because its slower?
Just checking in on this. @turf/buffer
6.5.0, published 2 months ago, doesn't have the fix. We use the @turf/buffer
package instead of turf
, so we can't use the v7 prerelease package. Any idea when this fix will make it to the @turf/buffer
package? Thx
It appears to me that the v7 of Turf is not ready. I have a simple React application that is using this version and uses the leaflet geoman drawing tool. When I draw a LineString on the map there is a reference error thrown:
Here is the codepen: https://codepen.io/gmarshall56/pen/xxLaWbr
Further, when I use the same v7 of Turf in my React application - not in a codepen - when I draw a line beginning in the northern hemisphere - specifically LA, California, USA down across the equator to and stop in Peru, Turf creates a buffer in the opposite direction. It appears Turf gets its lat/lng's confused when it has to work across the equator. See here, the LineString is green and the buffer is red:
Turf 7 has been released so this should be resolved for you @matthias-ccri, @gmarshall56, @funwhilelost, and @oloompa.
Hey guys! I have found what appears to be a bug in
@turf/buffer
.When buffering shapes close to the antimeridian, so that the buffered feature extends past the antimeridian, the resulting shape is corrupted. The out-of-bounds polygon coordinates get wrapped to the other side of the map. This only happens when the
needsTransverseMercator
code path kicks in — i.e. when the bbox is above 50 lat.Here is a gist with input and what I received as output. I ran
turf.buffer(input, 10)
using the version of turf on turfjs.org, using DevTools.https://gist.github.com/matthias-ccri/8b995c9e0be9c80c481d6a62ab7e7732
Does this look like a bug in @turf/buffer?