@turf/clusters-kmeans 6.4.0 → 7.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,14 +7,15 @@
7
7
  Takes a set of [points][1] and partition them into clusters using the k-mean .
8
8
  It uses the [k-means algorithm][2]
9
9
 
10
- **Parameters**
10
+ ### Parameters
11
11
 
12
- - `points` **[FeatureCollection][3]<[Point][4]>** to be clustered
13
- - `options` **[Object][5]** Optional parameters (optional, default `{}`)
14
- - `options.numberOfClusters` **[number][6]** numberOfClusters that will be generated (optional, default `Math.sqrt(numberOfPoints/2)`)
15
- - `options.mutate` **[boolean][7]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
12
+ * `points` **[FeatureCollection][3]<[Point][4]>** to be clustered
13
+ * `options` **[Object][5]** Optional parameters (optional, default `{}`)
16
14
 
17
- **Examples**
15
+ * `options.numberOfClusters` **[number][6]** numberOfClusters that will be generated (optional, default `Math.sqrt(numberOfPoints/2)`)
16
+ * `options.mutate` **[boolean][7]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
17
+
18
+ ### Examples
18
19
 
19
20
  ```javascript
20
21
  // create random points with random z-values in their properties
@@ -26,8 +27,8 @@ var clustered = turf.clustersKmeans(points, options);
26
27
  var addToMap = [clustered];
27
28
  ```
28
29
 
29
- Returns **[FeatureCollection][3]&lt;[Point][4]>** Clustered Points with an additional two properties associated to each Feature:- {number} cluster - the associated clusterId
30
- - {[number, number]} centroid - Centroid of the cluster [Longitude, Latitude]
30
+ Returns **[FeatureCollection][3]<[Point][4]>** Clustered Points with an additional two properties associated to each Feature:* {number} cluster - the associated clusterId
31
+ * {\[number, number]} centroid - Centroid of the cluster \[Longitude, Latitude]
31
32
 
32
33
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
33
34
 
package/dist/es/index.js CHANGED
@@ -22,8 +22,7 @@ import skmeans from "skmeans";
22
22
  * //addToMap
23
23
  * var addToMap = [clustered];
24
24
  */
25
- function clustersKmeans(points, options) {
26
- if (options === void 0) { options = {}; }
25
+ function clustersKmeans(points, options = {}) {
27
26
  // Default Params
28
27
  var count = points.features.length;
29
28
  options.numberOfClusters =
@@ -40,8 +39,7 @@ function clustersKmeans(points, options) {
40
39
  // create seed to avoid skmeans to drift
41
40
  var initialCentroids = data.slice(0, options.numberOfClusters);
42
41
  // create skmeans clusters
43
- var skmeansResult = skmeans(data, options.numberOfClusters, initialCentroids // typings are slightly wrong here
44
- );
42
+ var skmeansResult = skmeans(data, options.numberOfClusters, initialCentroids);
45
43
  // store centroids {clusterId: [number, number]}
46
44
  var centroids = {};
47
45
  skmeansResult.centroids.forEach(function (coord, idx) {
@@ -1,5 +1,5 @@
1
- import { FeatureCollection, Point, Properties } from "@turf/helpers";
2
- export declare type KmeansProps = Properties & {
1
+ import { FeatureCollection, Point, GeoJsonProperties } from "geojson";
2
+ export declare type KmeansProps = GeoJsonProperties & {
3
3
  cluster?: number;
4
4
  centroid?: [number, number];
5
5
  };
package/dist/js/index.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var clone_1 = __importDefault(require("@turf/clone"));
7
- var meta_1 = require("@turf/meta");
8
- var skmeans_1 = __importDefault(require("skmeans"));
3
+ const tslib_1 = require("tslib");
4
+ const clone_1 = tslib_1.__importDefault(require("@turf/clone"));
5
+ const meta_1 = require("@turf/meta");
6
+ const skmeans_1 = tslib_1.__importDefault(require("skmeans"));
9
7
  /**
10
8
  * Takes a set of {@link Point|points} and partition them into clusters using the k-mean .
11
9
  * It uses the [k-means algorithm](https://en.wikipedia.org/wiki/K-means_clustering)
@@ -27,8 +25,7 @@ var skmeans_1 = __importDefault(require("skmeans"));
27
25
  * //addToMap
28
26
  * var addToMap = [clustered];
29
27
  */
30
- function clustersKmeans(points, options) {
31
- if (options === void 0) { options = {}; }
28
+ function clustersKmeans(points, options = {}) {
32
29
  // Default Params
33
30
  var count = points.features.length;
34
31
  options.numberOfClusters =
@@ -45,8 +42,7 @@ function clustersKmeans(points, options) {
45
42
  // create seed to avoid skmeans to drift
46
43
  var initialCentroids = data.slice(0, options.numberOfClusters);
47
44
  // create skmeans clusters
48
- var skmeansResult = skmeans_1.default(data, options.numberOfClusters, initialCentroids // typings are slightly wrong here
49
- );
45
+ var skmeansResult = skmeans_1.default(data, options.numberOfClusters, initialCentroids);
50
46
  // store centroids {clusterId: [number, number]}
51
47
  var centroids = {};
52
48
  skmeansResult.centroids.forEach(function (coord, idx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/clusters-kmeans",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf clusters-kmeans module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -17,6 +17,7 @@
17
17
  "type": "git",
18
18
  "url": "git://github.com/Turfjs/turf.git"
19
19
  },
20
+ "funding": "https://opencollective.com/turf",
20
21
  "publishConfig": {
21
22
  "access": "public"
22
23
  },
@@ -50,16 +51,17 @@
50
51
  "docs": "node ../../scripts/generate-readmes",
51
52
  "test": "npm-run-all test:*",
52
53
  "test:tape": "ts-node -r esm test.js",
53
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
54
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
54
55
  },
55
56
  "devDependencies": {
56
- "@turf/centroid": "^6.4.0",
57
- "@turf/clusters": "^6.4.0",
58
- "@turf/random": "^6.4.0",
57
+ "@turf/centroid": "^7.0.0-alpha.0",
58
+ "@turf/clusters": "^7.0.0-alpha.0",
59
+ "@turf/random": "^7.0.0-alpha.0",
60
+ "@types/skmeans": "^0.11.2",
59
61
  "@types/tape": "*",
60
62
  "benchmark": "*",
61
63
  "chromatism": "*",
62
- "concaveman": "*",
64
+ "concaveman": "^1.2.1",
63
65
  "load-json-file": "*",
64
66
  "matrix-to-grid": "*",
65
67
  "npm-run-all": "*",
@@ -70,11 +72,12 @@
70
72
  "write-json-file": "*"
71
73
  },
72
74
  "dependencies": {
73
- "@turf/clone": "^6.4.0",
74
- "@turf/helpers": "^6.4.0",
75
- "@turf/invariant": "^6.4.0",
76
- "@turf/meta": "^6.4.0",
77
- "skmeans": "0.9.7"
75
+ "@turf/clone": "^7.0.0-alpha.0",
76
+ "@turf/helpers": "^7.0.0-alpha.0",
77
+ "@turf/invariant": "^7.0.0-alpha.0",
78
+ "@turf/meta": "^7.0.0-alpha.0",
79
+ "skmeans": "0.9.7",
80
+ "tslib": "^2.3.0"
78
81
  },
79
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
82
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
80
83
  }