@turf/clusters-dbscan 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 CHANGED
@@ -6,17 +6,18 @@
6
6
 
7
7
  Takes a set of [points][1] and partition them into clusters according to [https://en.wikipedia.org/wiki/DBSCAN][2] data clustering algorithm.
8
8
 
9
- **Parameters**
10
-
11
- - `points` **[FeatureCollection][3]<[Point][4]>** to be clustered
12
- - `maxDistance` **[number][5]** Maximum Distance between any point of the cluster to generate the clusters (kilometers only)
13
- - `options` **[Object][6]** Optional parameters (optional, default `{}`)
14
- - `options.units` **[string][7]** in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
15
- - `options.mutate` **[boolean][8]** Allows GeoJSON input to be mutated (optional, default `false`)
16
- - `options.minPoints` **[number][5]** Minimum number of points to generate a single cluster,
9
+ ### Parameters
10
+
11
+ * `points` **[FeatureCollection][3]<[Point][4]>** to be clustered
12
+ * `maxDistance` **[number][5]** Maximum Distance between any point of the cluster to generate the clusters (kilometers only)
13
+ * `options` **[Object][6]** Optional parameters (optional, default `{}`)
14
+
15
+ * `options.units` **[string][7]** in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
16
+ * `options.mutate` **[boolean][8]** Allows GeoJSON input to be mutated (optional, default `false`)
17
+ * `options.minPoints` **[number][5]** Minimum number of points to generate a single cluster,
17
18
  points which do not meet this requirement will be classified as an 'edge' or 'noise'. (optional, default `3`)
18
19
 
19
- **Examples**
20
+ ### Examples
20
21
 
21
22
  ```javascript
22
23
  // create random points with random z-values in their properties
@@ -28,8 +29,8 @@ var clustered = turf.clustersDbscan(points, maxDistance);
28
29
  var addToMap = [clustered];
29
30
  ```
30
31
 
31
- Returns **[FeatureCollection][3]&lt;[Point][4]>** Clustered Points with an additional two properties associated to each Feature:- {number} cluster - the associated clusterId
32
- - {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise')
32
+ Returns **[FeatureCollection][3]<[Point][4]>** Clustered Points with an additional two properties associated to each Feature:* {number} cluster - the associated clusterId
33
+ * {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise')
33
34
 
34
35
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
35
36
 
package/dist/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import clone from "@turf/clone";
2
2
  import distance from "@turf/distance";
3
3
  import { coordAll } from "@turf/meta";
4
- import { convertLength, } from "@turf/helpers";
4
+ import { convertLength } from "@turf/helpers";
5
5
  import clustering from "density-clustering";
6
6
  /**
7
7
  * Takes a set of {@link Point|points} and partition them into clusters according to {@link DBSCAN's|https://en.wikipedia.org/wiki/DBSCAN} data clustering algorithm.
@@ -26,13 +26,12 @@ import clustering from "density-clustering";
26
26
  * //addToMap
27
27
  * var addToMap = [clustered];
28
28
  */
29
- function clustersDbscan(points, maxDistance, options) {
29
+ function clustersDbscan(points, maxDistance, options = {}) {
30
30
  // Input validation being handled by Typescript
31
31
  // collectionOf(points, 'Point', 'points must consist of a FeatureCollection of only Points');
32
32
  // if (maxDistance === null || maxDistance === undefined) throw new Error('maxDistance is required');
33
33
  // if (!(Math.sign(maxDistance) > 0)) throw new Error('maxDistance is invalid');
34
34
  // if (!(minPoints === undefined || minPoints === null || Math.sign(minPoints) > 0)) throw new Error('options.minPoints is invalid');
35
- if (options === void 0) { options = {}; }
36
35
  // Clone points to prevent any mutations
37
36
  if (options.mutate !== true)
38
37
  points = clone(points);
@@ -1,6 +1,7 @@
1
- import { Properties, Units, FeatureCollection, Point } from "@turf/helpers";
1
+ import { GeoJsonProperties, FeatureCollection, Point } from "geojson";
2
+ import { Units } from "@turf/helpers";
2
3
  export declare type Dbscan = "core" | "edge" | "noise";
3
- export declare type DbscanProps = Properties & {
4
+ export declare type DbscanProps = GeoJsonProperties & {
4
5
  dbscan?: Dbscan;
5
6
  cluster?: number;
6
7
  };
package/dist/js/index.js CHANGED
@@ -1,13 +1,11 @@
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 distance_1 = __importDefault(require("@turf/distance"));
8
- var meta_1 = require("@turf/meta");
9
- var helpers_1 = require("@turf/helpers");
10
- var density_clustering_1 = __importDefault(require("density-clustering"));
3
+ const tslib_1 = require("tslib");
4
+ const clone_1 = tslib_1.__importDefault(require("@turf/clone"));
5
+ const distance_1 = tslib_1.__importDefault(require("@turf/distance"));
6
+ const meta_1 = require("@turf/meta");
7
+ const helpers_1 = require("@turf/helpers");
8
+ const density_clustering_1 = tslib_1.__importDefault(require("density-clustering"));
11
9
  /**
12
10
  * Takes a set of {@link Point|points} and partition them into clusters according to {@link DBSCAN's|https://en.wikipedia.org/wiki/DBSCAN} data clustering algorithm.
13
11
  *
@@ -31,13 +29,12 @@ var density_clustering_1 = __importDefault(require("density-clustering"));
31
29
  * //addToMap
32
30
  * var addToMap = [clustered];
33
31
  */
34
- function clustersDbscan(points, maxDistance, options) {
32
+ function clustersDbscan(points, maxDistance, options = {}) {
35
33
  // Input validation being handled by Typescript
36
34
  // collectionOf(points, 'Point', 'points must consist of a FeatureCollection of only Points');
37
35
  // if (maxDistance === null || maxDistance === undefined) throw new Error('maxDistance is required');
38
36
  // if (!(Math.sign(maxDistance) > 0)) throw new Error('maxDistance is invalid');
39
37
  // if (!(minPoints === undefined || minPoints === null || Math.sign(minPoints) > 0)) throw new Error('options.minPoints is invalid');
40
- if (options === void 0) { options = {}; }
41
38
  // Clone points to prevent any mutations
42
39
  if (options.mutate !== true)
43
40
  points = clone_1.default(points);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/clusters-dbscan",
3
- "version": "6.5.0",
3
+ "version": "7.0.0-alpha.1",
4
4
  "description": "turf clusters-dbscan module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -35,6 +35,7 @@
35
35
  "exports": {
36
36
  "./package.json": "./package.json",
37
37
  ".": {
38
+ "types": "./dist/js/index.d.ts",
38
39
  "import": "./dist/es/index.js",
39
40
  "require": "./dist/js/index.js"
40
41
  }
@@ -45,37 +46,38 @@
45
46
  "dist"
46
47
  ],
47
48
  "scripts": {
48
- "bench": "ts-node bench.js",
49
+ "bench": "tsx bench.js",
49
50
  "build": "npm-run-all build:*",
50
51
  "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
51
52
  "build:js": "tsc",
52
- "docs": "node ../../scripts/generate-readmes",
53
+ "docs": "tsx ../../scripts/generate-readmes",
53
54
  "test": "npm-run-all test:*",
54
- "test:tape": "ts-node -r esm test.js",
55
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
55
+ "test:tape": "tsx test.js",
56
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
56
57
  },
57
58
  "devDependencies": {
58
- "@turf/centroid": "^6.5.0",
59
- "@turf/clusters": "^6.5.0",
59
+ "@turf/centroid": "^7.0.0-alpha.1",
60
+ "@turf/clusters": "^7.0.0-alpha.1",
60
61
  "@types/density-clustering": "^1.3.0",
61
62
  "@types/tape": "*",
62
63
  "benchmark": "*",
63
64
  "chromatism": "*",
64
- "concaveman": "*",
65
+ "concaveman": "^1.2.1",
65
66
  "load-json-file": "*",
66
67
  "npm-run-all": "*",
67
68
  "tape": "*",
68
- "ts-node": "*",
69
69
  "tslint": "*",
70
+ "tsx": "*",
70
71
  "typescript": "*",
71
72
  "write-json-file": "*"
72
73
  },
73
74
  "dependencies": {
74
- "@turf/clone": "^6.5.0",
75
- "@turf/distance": "^6.5.0",
76
- "@turf/helpers": "^6.5.0",
77
- "@turf/meta": "^6.5.0",
78
- "density-clustering": "1.3.0"
75
+ "@turf/clone": "^7.0.0-alpha.1",
76
+ "@turf/distance": "^7.0.0-alpha.1",
77
+ "@turf/helpers": "^7.0.0-alpha.1",
78
+ "@turf/meta": "^7.0.0-alpha.1",
79
+ "density-clustering": "1.3.0",
80
+ "tslib": "^2.3.0"
79
81
  },
80
- "gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
82
+ "gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
81
83
  }