Expand description
Point clustering engine (supercluster-equivalent).
Provides zoom-based point clustering for GeoJSON point sources, matching the behaviour of MapLibre/Mapbox’s supercluster algorithm.
§Algorithm
- All input points are projected to a
[0, 1)Mercator plane. - At each zoom level from
max_zoomdown tomin_zoom, a spatial grid is used to find nearby points withinradius(in screen-pixel units, converted to world-space for each zoom). - Nearby points are merged into cluster nodes. Each cluster carries
point_countand optional aggregated properties. - Querying for a specific zoom returns a mix of cluster features
(for merged groups) and individual point features (for isolated
points or at zooms above
max_zoom).
§Usage
ⓘ
use rustial_engine::cluster::{PointCluster, ClusterOptions};
use rustial_engine::geometry::FeatureCollection;
let options = ClusterOptions {
radius: 50.0,
max_zoom: 16,
min_zoom: 0,
min_points: 2,
..Default::default()
};
let mut cluster = PointCluster::new(options);
cluster.load(&features);
let clustered = cluster.get_clusters_for_zoom(5);Structs§
- Cluster
Options - Options controlling point-clustering behaviour.
- Point
Cluster - A zoom-based point clustering index.