Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-centroid

Package Overview
Dependencies
Maintainers
9
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-centroid - npm Package Compare versions

Comparing version 1.1.3 to 3.0.0-canary.2f5f7167

6

bench.js

@@ -5,4 +5,4 @@ var centroid = require('./');

var boxFC = JSON.parse(fs.readFileSync(__dirname+'/fixtures/in/box.geojson'));
var blockFC = JSON.parse(fs.readFileSync(__dirname+'/fixtures/in/block.geojson'));
var boxFC = JSON.parse(fs.readFileSync(__dirname+'/test/in/box.geojson'));
var blockFC = JSON.parse(fs.readFileSync(__dirname+'/test/in/block.geojson'));

@@ -23,2 +23,2 @@ var suite = new Benchmark.Suite('turf-centroid');

})
.run();
.run();
var each = require('turf-meta').coordEach;
var point = require('turf-point');
var point = require('turf-helpers').point;
/**
* Takes one or more features and calculates the centroid using the arithmetic mean of all vertices.
* Takes one or more features and calculates the centroid using
* the mean of all vertices.
* This lessens the effect of small islands and artifacts when calculating
* the centroid of a set of polygons.
*
* @module turf/centroid
* @name centroid
* @category measurement

@@ -38,10 +39,10 @@ * @param {(Feature|FeatureCollection)} features input features

*/
module.exports = function(features) {
var xSum = 0, ySum = 0, len = 0;
each(features, function(coord) {
xSum += coord[0];
ySum += coord[1];
len++;
}, true);
return point([xSum / len, ySum / len]);
module.exports = function (features) {
var xSum = 0, ySum = 0, len = 0;
each(features, function (coord) {
xSum += coord[0];
ySum += coord[1];
len++;
}, true);
return point([xSum / len, ySum / len]);
};
{
"name": "turf-centroid",
"version": "1.1.3",
"version": "3.0.0-canary.2f5f7167",
"description": "turf centroid module",
"main": "index.js",
"scripts": {
"test": "node test.js",
"doc": "dox -r < index.js | doxme --readme > README.md"
"test": "node test.js"
},

@@ -28,11 +27,9 @@ "repository": {

"benchmark": "^1.0.0",
"tape": "^3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.3"
"tape": "^3.5.0"
},
"dependencies": {
"geojson-fixtures": "^0.5.0",
"turf-meta": "^1.0.2",
"turf-point": "^2.0.0"
"turf-meta": "^3.0.0-canary.2f5f7167",
"turf-helpers": "^3.0.0-canary.2f5f7167"
}
}

Sorry, the diff of this file is not supported yet

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