turf-centroid
Advanced tools
Comparing version 1.1.3 to 3.0.0-canary.2f5f7167
@@ -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(); |
23
index.js
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2
67
0
4995
7
1
+ Addedturf-helpers@3.0.12(transitive)
+ Addedturf-meta@3.0.12(transitive)
- Removedturf-point@^2.0.0
- Removedturf-meta@1.0.2(transitive)
- Removedturf-point@2.0.1(transitive)