pub struct PointCluster { /* private fields */ }Expand description
A zoom-based point clustering index.
Load a set of point features, then query clustered results at any zoom level. The algorithm mirrors MapLibre/Mapbox supercluster.
Implementations§
Source§impl PointCluster
impl PointCluster
Sourcepub fn new(options: ClusterOptions) -> Self
pub fn new(options: ClusterOptions) -> Self
Create a new (empty) cluster index with the given options.
Sourcepub fn load(&mut self, features: &FeatureCollection)
pub fn load(&mut self, features: &FeatureCollection)
Load (or replace) the point features and build the cluster index.
Non-point features are silently ignored.
Sourcepub fn get_clusters_for_zoom(&self, zoom: u8) -> FeatureCollection
pub fn get_clusters_for_zoom(&self, zoom: u8) -> FeatureCollection
Return the clustered features for a given zoom level.
Features with point_count > 1 are clusters; their properties
include cluster: true, cluster_id, and point_count.
Individual points carry their original properties.
Sourcepub fn get_cluster_expansion_zoom(&self, cluster_id: u32) -> Option<u8>
pub fn get_cluster_expansion_zoom(&self, cluster_id: u32) -> Option<u8>
Return the zoom level at which a cluster expands (breaks into
its children). Returns None if the id is not a cluster.
Sourcepub fn get_cluster_children(&self, cluster_id: u32) -> Option<Vec<Feature>>
pub fn get_cluster_children(&self, cluster_id: u32) -> Option<Vec<Feature>>
Return the immediate children of a cluster (may be sub-clusters
or original points). Returns None if the id is not a cluster.
Sourcepub fn get_cluster_leaves(
&self,
cluster_id: u32,
limit: usize,
offset: usize,
) -> Option<Vec<Feature>>
pub fn get_cluster_leaves( &self, cluster_id: u32, limit: usize, offset: usize, ) -> Option<Vec<Feature>>
Return all original (leaf) points contained in a cluster.
limit caps the result size. offset skips the first N leaves.
Sourcepub fn input_count(&self) -> usize
pub fn input_count(&self) -> usize
Number of original input points loaded.