Skip to main content

PointCluster

Struct PointCluster 

Source
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

Source

pub fn new(options: ClusterOptions) -> Self

Create a new (empty) cluster index with the given options.

Source

pub fn load(&mut self, features: &FeatureCollection)

Load (or replace) the point features and build the cluster index.

Non-point features are silently ignored.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn input_count(&self) -> usize

Number of original input points loaded.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.