Supercluster
Reference implementation
A very fast Rust library for geospatial point clustering. This library is deeply inspired by Mapbox's supercluster JS library and blog post.
Features

-
load(points): Loads an array of GeoJSON Feature objects. Each feature'sgeometrymust be a GeoJSON Point. -
get_clusters(bbox, zoom): For the givenbboxarray ([westLng, southLat, eastLng, northLat]) and integerzoom, returns an array of clusters and points as GeoJSON Feature objects. -
get_tile(z, x, y): For a given zoom and x/y coordinates, returns a geojson-vt-compatible JSON tile object with cluster/point features. -
get_children(cluster_id): Returns the children of a cluster (on the next zoom level) given its id (cluster_idvalue from feature properties). -
get_leaves(cluster_id, limit, offset): Returns all the points of a cluster (given itscluster_id), with pagination support. -
get_cluster_expansion_zoom(cluster_id): Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature) given the cluster'scluster_id.
Usage
Run the following Cargo command in your project directory:
extern crate supercluster;
use ;
Options
| Option | Description |
|---|---|
| min_zoom | Minimum zoom level at which clusters are generated. |
| max_zoom | Maximum zoom level at which clusters are generated. |
| min_points | Minimum number of points to form a cluster. |
| radius | Cluster radius, in pixels. |
| extent | (Tiles) Tile extent. Radius is calculated relative to this value. |
| node_size | Size of the KD-tree leaf node. Affects performance. |
Contributing
- Build:
- Test:
- Run clippy:
- Generate documentation in HTML format:
