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.1.0 to 1.1.1

3

index.js

@@ -10,3 +10,4 @@ var each = require('turf-meta').coordEach;

* @module turf/centroid
* @param {FeatureCollection} fc a {@link Feature} or FeatureCollection of any type
* @category measurement
* @param {GeoJSON} features a {@link Feature} or FeatureCollection of any type
* @return {Point} a Point feature at the centroid of the input feature(s)

@@ -13,0 +14,0 @@ * @example

{
"name": "turf-centroid",
"version": "1.1.0",
"version": "1.1.1",
"description": "turf centroid module",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ # turf-centroid

### `turf.centroid(fc)`
### `turf.centroid(features)`

@@ -18,5 +18,5 @@ Takes a Feature or FeatureCollection of any type and calculates the centroid using the arithmetic mean of all vertices.

| parameter | type | description |
| --------- | ----------------- | ------------------------------------------ |
| `fc` | FeatureCollection | a Feature or FeatureCollection of any type |
| parameter | type | description |
| ---------- | ------- | ------------------------------------------ |
| `features` | GeoJSON | a Feature or FeatureCollection of any type |

@@ -27,13 +27,23 @@

```js
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]
};

@@ -40,0 +50,0 @@ //=result

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