@mapgis/supercluster 7.1.0 → 16.0.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.
Files changed (2) hide show
  1. package/README.md +105 -105
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,105 +1,105 @@
1
- # supercluster [![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects) [![Build Status](https://travis-ci.org/mapbox/supercluster.svg?branch=main)](https://travis-ci.org/mapbox/supercluster)
2
-
3
- A very fast JavaScript library for geospatial point clustering for browsers and Node.
4
-
5
- ```html
6
- <script src="https://unpkg.com/supercluster@6.0.2/dist/supercluster.min.js"></script>
7
- ```
8
-
9
- ```js
10
- const index = new Supercluster({
11
- radius: 40,
12
- maxZoom: 16
13
- });
14
- index.load(points);
15
- index.getClusters([-180, -85, 180, 85], 2);
16
- ```
17
-
18
- Clustering 6 million points in Leaflet:
19
-
20
- ![clusters2](https://cloud.githubusercontent.com/assets/25395/11857351/43407b46-a40c-11e5-8662-e99ab1cd2cb7.gif)
21
-
22
- ## Install
23
-
24
- Install using NPM (`npm install supercluster`) or Yarn (`yarn add supercluster`), then:
25
-
26
- ```js
27
- // import as a ES module
28
- import Supercluster from 'supercluster';
29
-
30
- // or require in Node / Browserify
31
- const Supercluster = require('supercluster');
32
- ```
33
-
34
- Or use a browser build directly:
35
-
36
- ```html
37
- <script src="https://unpkg.com/supercluster@6.0.2/dist/supercluster.min.js"></script>
38
- ```
39
-
40
- ## Methods
41
-
42
- #### `load(points)`
43
-
44
- Loads an array of [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) objects. Each feature's `geometry` must be a [GeoJSON Point](https://tools.ietf.org/html/rfc7946#section-3.1.2). Once loaded, index is immutable.
45
-
46
- #### `getClusters(bbox, zoom)`
47
-
48
- For the given `bbox` array (`[westLng, southLat, eastLng, northLat]`) and integer `zoom`, returns an array of clusters and points as [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) objects.
49
-
50
- #### `getTile(z, x, y)`
51
-
52
- For a given zoom and x/y coordinates, returns a [geojson-vt](https://github.com/mapbox/geojson-vt)-compatible JSON tile object with cluster/point features.
53
-
54
- #### `getChildren(clusterId)`
55
-
56
- Returns the children of a cluster (on the next zoom level) given its id (`cluster_id` value from feature properties).
57
-
58
- #### `getLeaves(clusterId, limit = 10, offset = 0)`
59
-
60
- Returns all the points of a cluster (given its `cluster_id`), with pagination support:
61
- `limit` is the number of points to return (set to `Infinity` for all points),
62
- and `offset` is the amount of points to skip (for pagination).
63
-
64
- #### `getClusterExpansionZoom(clusterId)`
65
-
66
- Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature) given the cluster's `cluster_id`.
67
-
68
- ## Options
69
-
70
- | Option | Default | Description |
71
- |------------|---------|-------------------------------------------------------------------|
72
- | minZoom | 0 | Minimum zoom level at which clusters are generated. |
73
- | maxZoom | 16 | Maximum zoom level at which clusters are generated. |
74
- | minPoints | 2 | Minimum number of points to form a cluster. |
75
- | radius | 40 | Cluster radius, in pixels. |
76
- | extent | 512 | (Tiles) Tile extent. Radius is calculated relative to this value. |
77
- | nodeSize | 64 | Size of the KD-tree leaf node. Affects performance. |
78
- | log | false | Whether timing info should be logged. |
79
- | generateId | false | Whether to generate ids for input features in vector tiles. |
80
-
81
- ### Property map/reduce options
82
-
83
- In addition to the options above, supercluster supports property aggregation with the following two options:
84
-
85
- - `map`: a function that returns cluster properties corresponding to a single point.
86
- - `reduce`: a reduce function that merges properties of two clusters into one.
87
-
88
- Example of setting up a `sum` cluster property that accumulates the sum of `myValue` property values:
89
-
90
- ```js
91
- const index = new Supercluster({
92
- map: (props) => ({sum: props.myValue}),
93
- reduce: (accumulated, props) => { accumulated.sum += props.sum; }
94
- });
95
- ```
96
-
97
- Note that `reduce` must not mutate the second argument (`props`).
98
-
99
- ## Developing Supercluster
100
-
101
- ```
102
- npm install # install dependencies
103
- npm run build # generate dist/supercluster.js and dist/supercluster.min.js
104
- npm test # run tests
105
- ```
1
+ # supercluster [![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects) [![Build Status](https://travis-ci.org/mapbox/supercluster.svg?branch=main)](https://travis-ci.org/mapbox/supercluster)
2
+
3
+ A very fast JavaScript library for geospatial point clustering for browsers and Node.
4
+
5
+ ```html
6
+ <script src="https://unpkg.com/supercluster@6.0.2/dist/supercluster.min.js"></script>
7
+ ```
8
+
9
+ ```js
10
+ const index = new Supercluster({
11
+ radius: 40,
12
+ maxZoom: 16
13
+ });
14
+ index.load(points);
15
+ index.getClusters([-180, -85, 180, 85], 2);
16
+ ```
17
+
18
+ Clustering 6 million points in Leaflet:
19
+
20
+ ![clusters2](https://cloud.githubusercontent.com/assets/25395/11857351/43407b46-a40c-11e5-8662-e99ab1cd2cb7.gif)
21
+
22
+ ## Install
23
+
24
+ Install using NPM (`npm install supercluster`) or Yarn (`yarn add supercluster`), then:
25
+
26
+ ```js
27
+ // import as a ES module
28
+ import Supercluster from 'supercluster';
29
+
30
+ // or require in Node / Browserify
31
+ const Supercluster = require('supercluster');
32
+ ```
33
+
34
+ Or use a browser build directly:
35
+
36
+ ```html
37
+ <script src="https://unpkg.com/supercluster@6.0.2/dist/supercluster.min.js"></script>
38
+ ```
39
+
40
+ ## Methods
41
+
42
+ #### `load(points)`
43
+
44
+ Loads an array of [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) objects. Each feature's `geometry` must be a [GeoJSON Point](https://tools.ietf.org/html/rfc7946#section-3.1.2). Once loaded, index is immutable.
45
+
46
+ #### `getClusters(bbox, zoom)`
47
+
48
+ For the given `bbox` array (`[westLng, southLat, eastLng, northLat]`) and integer `zoom`, returns an array of clusters and points as [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) objects.
49
+
50
+ #### `getTile(z, x, y)`
51
+
52
+ For a given zoom and x/y coordinates, returns a [geojson-vt](https://github.com/mapbox/geojson-vt)-compatible JSON tile object with cluster/point features.
53
+
54
+ #### `getChildren(clusterId)`
55
+
56
+ Returns the children of a cluster (on the next zoom level) given its id (`cluster_id` value from feature properties).
57
+
58
+ #### `getLeaves(clusterId, limit = 10, offset = 0)`
59
+
60
+ Returns all the points of a cluster (given its `cluster_id`), with pagination support:
61
+ `limit` is the number of points to return (set to `Infinity` for all points),
62
+ and `offset` is the amount of points to skip (for pagination).
63
+
64
+ #### `getClusterExpansionZoom(clusterId)`
65
+
66
+ Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature) given the cluster's `cluster_id`.
67
+
68
+ ## Options
69
+
70
+ | Option | Default | Description |
71
+ |------------|---------|-------------------------------------------------------------------|
72
+ | minZoom | 0 | Minimum zoom level at which clusters are generated. |
73
+ | maxZoom | 16 | Maximum zoom level at which clusters are generated. |
74
+ | minPoints | 2 | Minimum number of points to form a cluster. |
75
+ | radius | 40 | Cluster radius, in pixels. |
76
+ | extent | 512 | (Tiles) Tile extent. Radius is calculated relative to this value. |
77
+ | nodeSize | 64 | Size of the KD-tree leaf node. Affects performance. |
78
+ | log | false | Whether timing info should be logged. |
79
+ | generateId | false | Whether to generate ids for input features in vector tiles. |
80
+
81
+ ### Property map/reduce options
82
+
83
+ In addition to the options above, supercluster supports property aggregation with the following two options:
84
+
85
+ - `map`: a function that returns cluster properties corresponding to a single point.
86
+ - `reduce`: a reduce function that merges properties of two clusters into one.
87
+
88
+ Example of setting up a `sum` cluster property that accumulates the sum of `myValue` property values:
89
+
90
+ ```js
91
+ const index = new Supercluster({
92
+ map: (props) => ({sum: props.myValue}),
93
+ reduce: (accumulated, props) => { accumulated.sum += props.sum; }
94
+ });
95
+ ```
96
+
97
+ Note that `reduce` must not mutate the second argument (`props`).
98
+
99
+ ## Developing Supercluster
100
+
101
+ ```
102
+ npm install # install dependencies
103
+ npm run build # generate dist/supercluster.js and dist/supercluster.min.js
104
+ npm test # run tests
105
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapgis/supercluster",
3
- "version": "7.1.0",
3
+ "version": "16.0.0",
4
4
  "description": "A very fast geospatial point clustering library.",
5
5
  "main": "dist/supercluster.js",
6
6
  "module": "index.js",
@@ -12,7 +12,7 @@
12
12
  "cov": "c8 npm run test",
13
13
  "bench": "node --expose-gc -r esm bench.js",
14
14
  "build": "mkdir dist && rollup -c",
15
- "prepublishOnly": "npm run build"
15
+ "prepublishOnly": "npm run test && npm run build"
16
16
  },
17
17
  "files": [
18
18
  "index.js",