Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
return featureCollection(results);
}
// Project GeoJSON to Transverse Mercator projection (convert to Meters)
var projected;
var bbox = turfBbox(geojson);
var needsTransverseMercator = bbox[1] > 50 && bbox[3] > 50;
if (needsTransverseMercator) {
projected = {
type: geometry.type,
coordinates: projectCoords(geometry.coordinates, defineProjection(geometry))
};
} else {
projected = toMercator(geometry);
}
// JSTS buffer operation
var reader = new GeoJSONReader();
var geom = reader.read(projected);
var distance = radiansToLength(lengthToRadians(radius, units), 'meters');
var buffered = BufferOp.bufferOp(geom, distance);
var writer = new GeoJSONWriter();
buffered = writer.write(buffered);
// Detect if empty geometries
if (coordsIsNaN(buffered.coordinates)) return undefined;
// Unproject coordinates (convert to Degrees)
var result;
if (needsTransverseMercator) {