https://github.com/chargetrip/supercluster-rs
A very fast Rust crate for geospatial point clustering.
https://github.com/chargetrip/supercluster-rs
clustering-algorithm geospatial mapbox-vector-tile maps mvt rust supercluster tile
Last synced: 2 months ago
JSON representation
A very fast Rust crate for geospatial point clustering.
- Host: GitHub
- URL: https://github.com/chargetrip/supercluster-rs
- Owner: chargetrip
- License: mit
- Created: 2023-11-06T09:01:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T13:24:09.000Z (12 months ago)
- Last Synced: 2024-10-21T21:08:12.580Z (12 months ago)
- Topics: clustering-algorithm, geospatial, mapbox-vector-tile, maps, mvt, rust, supercluster, tile
- Language: Rust
- Homepage: https://crates.io/crates/supercluster
- Size: 78.1 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Supercluster
A high-performance Rust crate for geospatial and non-geospatial point clustering.
## Reference implementation
[](https://github.com/chargetrip/supercluster-rs/actions/workflows/test.yml)
[](https://docs.rs/supercluster)
[](https://crates.io/crates/supercluster)


[](https://codecov.io/gh/chargetrip/supercluster-rs)
## Documentation
For more in-depth details, please refer to the full [documentation](https://docs.rs/supercluster).
If you encounter any issues or have questions that are not addressed in the documentation, feel free to [submit an issue](https://github.com/chargetrip/supercluster-rs/issues).
This crate was initially inspired by Mapbox's supercluster [blog post](https://blog.mapbox.com/clustering-millions-of-points-on-a-map-with-supercluster-272046ec5c97).
## Usage
To use the `supercluster` crate in your project, add it to your `Cargo.toml`:
```toml
[dependencies]
supercluster = "3.0.4"
```You can also include additional features, such as logging, by specifying them in your `Cargo.toml`:
```toml
[dependencies]
supercluster = { version = "3.0.4", features = ["log", "serde", "cluster_metadata"] }
```Below is an example of how to create and run a supercluster using the crate.
This example demonstrates how to build supercluster options, create a new supercluster, and get a tile.
For more detailed information and advanced usage, please refer to the full [documentation](https://docs.rs/supercluster).```rust
use supercluster::{ CoordinateSystem, Supercluster, SuperclusterError };fn main() -> Result<(), SuperclusterError> {
// Set the configuration settings
let options = Supercluster::builder()
.radius(40.0)
.extent(512.0)
.min_points(2)
.max_zoom(16)
.coordinate_system(CoordinateSystem::LatLng)
.build();// Create a new instance with the specified configuration settings
let mut cluster = Supercluster::new(options);// Create a a list of features
let features = Supercluster::feature_builder()
.add_point(vec![0.0, 0.0])
.build();// Load a list of features into the supercluster
let index = cluster.load(features)?;index.get_tile(0, 0.0, 0.0)?;
Ok(())
}
```## Benchmarks
We use the `criterion` crate to benchmark the performance of the `supercluster` crate.
Benchmarks help us understand the performance characteristics of supercluster and identify areas for optimization.
We have several benchmark scenarios to test different aspects of supercluster:
- **Getting a Tile**: Tests the performance of retrieving a tile from the `Supercluster`.
- **Getting Clusters**: Tests the performance of retrieving clusters for a given bounding box and zoom level.
- **Loading a Feature Collection**: Tests the performance of loading a `FeatureCollection` into the `Supercluster`.For more detailed benchmark scenarios, please refer to the [`benches`](https://github.com/chargetrip/supercluster-rs/tree/main/benches) directory in the repository.
## Safety
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.
## Contributing
🎈 Thanks for your help improving the project! We are so happy to have you!
We have a [contributing guide](https://github.com/chargetrip/supercluster-rs/blob/main/CONTRIBUTING.md) to help you get involved in the project.
## Sponsors