New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@turf/buffer

Package Overview
Dependencies
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/buffer - npm Package Compare versions

Comparing version 4.7.3 to 4.7.4

43

index.js

@@ -6,4 +6,8 @@ var d3 = require('d3-geo');

var helpers = require('@turf/helpers');
var turfBbox = require('@turf/bbox');
var projection = require('@turf/projection');
var toWgs84 = projection.toWgs84;
var feature = helpers.feature;
var geomEach = meta.geomEach;
var toMercator = projection.toMercator;
var featureEach = meta.featureEach;

@@ -43,5 +47,2 @@ var featureCollection = helpers.featureCollection;

// prevent input mutation
// geojson = JSON.parse(JSON.stringify(geojson));
// default params

@@ -88,4 +89,3 @@ steps = steps || 64;

// Geometry Types faster than jsts
switch (geometry.type) {
case 'GeometryCollection':
if (geometry.type === 'GeometryCollection') {
var results = [];

@@ -100,12 +100,20 @@ geomEach(geojson, function (geometry) {

// Project GeoJSON to Transverse Mercator projection (convert to Meters)
var distance = radiansToDistance(distanceToRadians(radius, units), 'meters');
var projection = defineProjection(geojson);
var projected = {
type: geometry.type,
coordinates: projectCoords(geometry.coordinates, projection)
};
var projected;
var bbox = turfBbox(geojson);
var needsTransverseMercator = bbox[1] > 50 && bbox[3] > 50;
if (needsTransverseMercator) {
var projection = defineProjection(geometry);
projected = {
type: geometry.type,
coordinates: projectCoords(geometry.coordinates, projection)
};
} else {
projected = toMercator(geometry);
}
// JSTS buffer operation
var reader = new jsts.io.GeoJSONReader();
var geom = reader.read(projected);
var distance = radiansToDistance(distanceToRadians(radius, units), 'meters');
var buffered = geom.buffer(distance);

@@ -119,4 +127,13 @@ var writer = new jsts.io.GeoJSONWriter();

// Unproject coordinates (convert to Degrees)
buffered.coordinates = unprojectCoords(buffered.coordinates, projection);
return feature(buffered, properties);
var result;
if (needsTransverseMercator) {
result = {
type: buffered.type,
coordinates: unprojectCoords(buffered.coordinates, projection)
};
} else {
result = toWgs84(buffered);
}
return (result.geometry) ? result : feature(result, properties);
}

@@ -123,0 +140,0 @@

{
"name": "@turf/buffer",
"version": "4.7.3",
"version": "4.7.4",
"description": "turf buffer module",

@@ -31,3 +31,4 @@ "main": "index.js",

"Tom MacWright <@tmcw>",
"Denis Carriere <@DenisCarriere>"
"Denis Carriere <@DenisCarriere>",
"Stefano Borghi <@stebogit>"
],

@@ -47,5 +48,7 @@ "license": "MIT",

"dependencies": {
"@turf/center": "^4.7.3",
"@turf/helpers": "^4.7.3",
"@turf/meta": "^4.7.3",
"@turf/bbox": "^4.7.1",
"@turf/center": "4.7.1",
"@turf/helpers": "4.7.1",
"@turf/meta": "4.7.1",
"@turf/projection": "^4.7.1",
"d3-geo": "^1.6.3",

@@ -52,0 +55,0 @@ "jsts": "1.3.0"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc