@turf/clusters 6.5.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 +28 -28
- package/dist/es/index.js +0 -0
- package/dist/js/index.d.ts +4 -4
- package/dist/js/index.js +2 -2
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
Get Cluster
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* `geojson` **[FeatureCollection][1]** GeoJSON Features
|
|
12
|
+
* `filter` **any** Filter used on GeoJSON properties to get Cluster
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### Examples
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
17
|
var geojson = turf.featureCollection([
|
|
@@ -44,11 +44,11 @@ Callback for clusterEach
|
|
|
44
44
|
|
|
45
45
|
Type: [Function][2]
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### Parameters
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
* `cluster` **[FeatureCollection][1]?** The current cluster being processed.
|
|
50
|
+
* `clusterValue` **any?** Value used to create cluster being processed.
|
|
51
|
+
* `currentIndex` **[number][3]?** The index of the current element being processed in the array.Starts at index 0
|
|
52
52
|
|
|
53
53
|
Returns **void**
|
|
54
54
|
|
|
@@ -56,13 +56,13 @@ Returns **void**
|
|
|
56
56
|
|
|
57
57
|
clusterEach
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
### Parameters
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
* `geojson` **[FeatureCollection][1]** GeoJSON Features
|
|
62
|
+
* `property` **([string][4] | [number][3])** GeoJSON property key/value used to create clusters
|
|
63
|
+
* `callback` **[Function][2]** a method that takes (cluster, clusterValue, currentIndex)
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
### Examples
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
68
|
var geojson = turf.featureCollection([
|
|
@@ -107,37 +107,37 @@ on whether the reduce method has an initialValue argument.
|
|
|
107
107
|
|
|
108
108
|
If an initialValue is provided to the reduce method:
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
* The previousValue argument is initialValue.
|
|
111
|
+
* The currentValue argument is the value of the first element present in the array.
|
|
112
112
|
|
|
113
113
|
If an initialValue is not provided:
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
* The previousValue argument is the value of the first element present in the array.
|
|
116
|
+
* The currentValue argument is the value of the second element present in the array.
|
|
117
117
|
|
|
118
118
|
Type: [Function][2]
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
### Parameters
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
* `previousValue` **any?** The accumulated value previously returned in the last invocation
|
|
123
123
|
of the callback, or initialValue, if supplied.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
* `cluster` **[FeatureCollection][1]?** The current cluster being processed.
|
|
125
|
+
* `clusterValue` **any?** Value used to create cluster being processed.
|
|
126
|
+
* `currentIndex` **[number][3]?** The index of the current element being processed in the
|
|
127
127
|
array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
|
|
128
128
|
|
|
129
129
|
## clusterReduce
|
|
130
130
|
|
|
131
131
|
Reduce clusters in GeoJSON Features, similar to Array.reduce()
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
### Parameters
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
* `geojson` **[FeatureCollection][1]** GeoJSON Features
|
|
136
|
+
* `property` **([string][4] | [number][3])** GeoJSON property key/value used to create clusters
|
|
137
|
+
* `callback` **[Function][2]** a method that takes (previousValue, cluster, clusterValue, currentIndex)
|
|
138
|
+
* `initialValue` **any?** Value to use as the first argument to the first call of the callback.
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
### Examples
|
|
141
141
|
|
|
142
142
|
```javascript
|
|
143
143
|
var geojson = turf.featureCollection([
|
package/dist/es/index.js
CHANGED
|
File without changes
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeatureCollection } from "
|
|
1
|
+
import { FeatureCollection, GeometryObject } from "geojson";
|
|
2
2
|
/**
|
|
3
3
|
* Get Cluster
|
|
4
4
|
*
|
|
@@ -28,7 +28,7 @@ import { FeatureCollection } from "@turf/helpers";
|
|
|
28
28
|
* turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
|
|
29
29
|
* //= 1
|
|
30
30
|
*/
|
|
31
|
-
export declare function getCluster<G extends
|
|
31
|
+
export declare function getCluster<G extends GeometryObject, P = any>(geojson: FeatureCollection<G, P>, filter: any): FeatureCollection<G, P>;
|
|
32
32
|
/**
|
|
33
33
|
* Callback for clusterEach
|
|
34
34
|
*
|
|
@@ -77,7 +77,7 @@ export declare function getCluster<G extends any, P = any>(geojson: FeatureColle
|
|
|
77
77
|
* values.push(clusterValue);
|
|
78
78
|
* });
|
|
79
79
|
*/
|
|
80
|
-
export declare function clusterEach<G
|
|
80
|
+
export declare function clusterEach<G extends GeometryObject, P = any>(geojson: FeatureCollection<G, P>, property: number | string, callback: (cluster: FeatureCollection<G, P>, clusterValue?: any, currentIndex?: number) => void): void;
|
|
81
81
|
/**
|
|
82
82
|
* Callback for clusterReduce
|
|
83
83
|
*
|
|
@@ -141,7 +141,7 @@ export declare function clusterEach<G = any, P = any>(geojson: FeatureCollection
|
|
|
141
141
|
* return previousValue.concat(clusterValue);
|
|
142
142
|
* }, []);
|
|
143
143
|
*/
|
|
144
|
-
export declare function clusterReduce<G
|
|
144
|
+
export declare function clusterReduce<G extends GeometryObject, P = any>(geojson: FeatureCollection<G, P>, property: number | string, callback: (previousValue: any | undefined, cluster: FeatureCollection<G, P>, clusterValue?: any, currentIndex?: number) => void, initialValue?: any): void;
|
|
145
145
|
/**
|
|
146
146
|
* Create Bins
|
|
147
147
|
*
|
package/dist/js/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const meta_1 = require("@turf/meta");
|
|
4
|
+
const helpers_1 = require("@turf/helpers");
|
|
5
5
|
/**
|
|
6
6
|
* Get Cluster
|
|
7
7
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/clusters",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf clusters module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"docs": "node ../../scripts/generate-readmes",
|
|
49
49
|
"test": "npm-run-all test:*",
|
|
50
50
|
"test:tape": "ts-node -r esm test.js",
|
|
51
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
51
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/tape": "*",
|
|
@@ -60,8 +60,9 @@
|
|
|
60
60
|
"typescript": "*"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@turf/helpers": "^
|
|
64
|
-
"@turf/meta": "^
|
|
63
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
64
|
+
"@turf/meta": "^7.0.0-alpha.0",
|
|
65
|
+
"tslib": "^2.3.0"
|
|
65
66
|
},
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
67
68
|
}
|