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

turf-centroid

Package Overview
Dependencies
Maintainers
8
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.0.2 to 1.0.3

28

index.js

@@ -13,13 +13,23 @@ var each = require('turf-meta').coordEach;

* @example
* var poly = turf.polygon([[
* [105.818939,21.004714],
* [105.818939,21.061754],
* [105.890007,21.061754],
* [105.890007,21.004714],
* [105.818939,21.004714]
* ]]);
* var poly = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[
* [105.818939,21.004714],
* [105.818939,21.061754],
* [105.890007,21.061754],
* [105.890007,21.004714],
* [105.818939,21.004714]
* ]]
* }
* };
*
* var centroidPt = turf.centroid(poly);
*
* var result = turf.featurecollection([poly, centroidPt]);
* var result = {
* "type": "FeatureCollection",
* "features": [poly, centroidPt]
* };
*

@@ -34,4 +44,4 @@ * //=result

len++;
});
}, true);
return point([xSum / len, ySum / len]);
};
{
"name": "turf-centroid",
"version": "1.0.2",
"version": "1.0.3",
"description": "turf centroid module",

@@ -28,10 +28,10 @@ "main": "index.js",

"benchmark": "^1.0.0",
"tape": "^3.0.3",
"tape": "^3.5.0",
"dox": "^0.6.1",
"doxme": "^1.4.2"
"doxme": "^1.4.3"
},
"dependencies": {
"turf-meta": "^1.0.1",
"turf-meta": "^1.0.2",
"turf-point": "^2.0.0"
}
}
var test = require('tape');
var center = require('./');
var fc = require('./geojson/fc');
var fc = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
60.46875,
39.90973623453719
],
[
60.46875,
47.27922900257082
],
[
70.6640625,
47.27922900257082
],
[
70.6640625,
39.90973623453719
],
[
60.46875,
39.90973623453719
]
]
]
}
}
]
};
test('center', function(t){

@@ -9,5 +45,9 @@ var centered = center(fc);

t.ok(centered, 'should return the proper center for a FeatureCollection');
t.deepEqual(centered.geometry.coordinates, [96.3, -0.25]);
t.deepEqual(centered.geometry.coordinates, [65.56640625, 43.59448261855401]);
var polyCenter = center(fc.features[0])
t.ok(polyCenter, 'should return the proper center for a Polygon');
t.deepEqual(centered, polyCenter);
t.end();
});
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