@turf/clusters-kmeans 6.5.0 → 7.0.0-alpha.1
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 +9 -8
- package/dist/es/index.js +1 -2
- package/dist/js/index.d.ts +2 -2
- package/dist/js/index.js +5 -8
- package/package.json +18 -16
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
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
**
|
|
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]
|
|
30
|
-
|
|
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 =
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FeatureCollection, Point,
|
|
2
|
-
export declare type KmeansProps =
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/clusters-kmeans",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "turf clusters-kmeans module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"exports": {
|
|
35
35
|
"./package.json": "./package.json",
|
|
36
36
|
".": {
|
|
37
|
+
"types": "./dist/js/index.d.ts",
|
|
37
38
|
"import": "./dist/es/index.js",
|
|
38
39
|
"require": "./dist/js/index.js"
|
|
39
40
|
}
|
|
@@ -44,39 +45,40 @@
|
|
|
44
45
|
"dist"
|
|
45
46
|
],
|
|
46
47
|
"scripts": {
|
|
47
|
-
"bench": "
|
|
48
|
+
"bench": "tsx bench.js",
|
|
48
49
|
"build": "npm-run-all build:*",
|
|
49
50
|
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
|
|
50
51
|
"build:js": "tsc",
|
|
51
|
-
"docs": "
|
|
52
|
+
"docs": "tsx ../../scripts/generate-readmes",
|
|
52
53
|
"test": "npm-run-all test:*",
|
|
53
|
-
"test:tape": "
|
|
54
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
54
|
+
"test:tape": "tsx test.js",
|
|
55
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@turf/centroid": "^
|
|
58
|
-
"@turf/clusters": "^
|
|
59
|
-
"@turf/random": "^
|
|
58
|
+
"@turf/centroid": "^7.0.0-alpha.1",
|
|
59
|
+
"@turf/clusters": "^7.0.0-alpha.1",
|
|
60
|
+
"@turf/random": "^7.0.0-alpha.1",
|
|
60
61
|
"@types/skmeans": "^0.11.2",
|
|
61
62
|
"@types/tape": "*",
|
|
62
63
|
"benchmark": "*",
|
|
63
64
|
"chromatism": "*",
|
|
64
|
-
"concaveman": "
|
|
65
|
+
"concaveman": "^1.2.1",
|
|
65
66
|
"load-json-file": "*",
|
|
66
67
|
"matrix-to-grid": "*",
|
|
67
68
|
"npm-run-all": "*",
|
|
68
69
|
"tape": "*",
|
|
69
|
-
"ts-node": "*",
|
|
70
70
|
"tslint": "*",
|
|
71
|
+
"tsx": "*",
|
|
71
72
|
"typescript": "*",
|
|
72
73
|
"write-json-file": "*"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"@turf/clone": "^
|
|
76
|
-
"@turf/helpers": "^
|
|
77
|
-
"@turf/invariant": "^
|
|
78
|
-
"@turf/meta": "^
|
|
79
|
-
"skmeans": "0.9.7"
|
|
76
|
+
"@turf/clone": "^7.0.0-alpha.1",
|
|
77
|
+
"@turf/helpers": "^7.0.0-alpha.1",
|
|
78
|
+
"@turf/invariant": "^7.0.0-alpha.1",
|
|
79
|
+
"@turf/meta": "^7.0.0-alpha.1",
|
|
80
|
+
"skmeans": "0.9.7",
|
|
81
|
+
"tslib": "^2.3.0"
|
|
80
82
|
},
|
|
81
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
|
|
82
84
|
}
|