pub struct CrossTileSymbolIndex { /* private fields */ }Expand description
Cross-tile symbol index that deduplicates labels across tile boundaries.
This is the top-level entry point, keyed by style-layer id. Each style
layer has an independent [LayerCrossTileIndex] so that labels from
different layers do not interfere with each other.
§Usage
let mut index = CrossTileSymbolIndex::new();
// For each tile's symbol candidates:
let changed = index.assign("poi-labels", tile_id, instance_id, &mut entries);
// After placement, prune tiles no longer visible:
index.prune_stale("poi-labels", &active_instance_ids);
// When a tile is evicted from the cache:
index.remove_tile(&tile_id);Implementations§
Source§impl CrossTileSymbolIndex
impl CrossTileSymbolIndex
Sourcepub fn next_instance_id(&mut self) -> u64
pub fn next_instance_id(&mut self) -> u64
Allocate a unique instance ID for a tile registration.
Each call to assign should use a fresh instance ID
so the index can detect when a tile’s data has been replaced (e.g.
after a style change or data update).
Sourcepub fn assign(
&mut self,
layer_id: &str,
tile_id: TileId,
instance_id: u64,
candidates: &mut [SymbolCandidateEntry],
) -> bool
pub fn assign( &mut self, layer_id: &str, tile_id: TileId, instance_id: u64, candidates: &mut [SymbolCandidateEntry], ) -> bool
Register a tile’s symbol candidates and assign cross-tile IDs.
After this call, each entry in candidates will have a non-zero
assigned_cross_tile_id
that is stable across zoom transitions and tile reloads.
Returns true if any IDs changed (caller should re-run placement).
Sourcepub fn prune_stale(
&mut self,
layer_id: &str,
current_instance_ids: &HashSet<u64>,
) -> bool
pub fn prune_stale( &mut self, layer_id: &str, current_instance_ids: &HashSet<u64>, ) -> bool
Remove grids for tiles whose instance IDs are no longer active.
Call this after each placement frame with the set of instance IDs
that are still in use. Returns true if any stale grids were removed.
Sourcepub fn remove_tile(&mut self, tile_id: &TileId)
pub fn remove_tile(&mut self, tile_id: &TileId)
Remove all index entries for a specific tile across all layers.
Call this when a tile is evicted from the tile cache to release the associated cross-tile IDs.
Sourcepub fn prune_layers(&mut self, active_layers: &HashSet<String>)
pub fn prune_layers(&mut self, active_layers: &HashSet<String>)
Remove index state for layers that are no longer active.
active_layers is the set of style-layer IDs currently in use.
Any layer not in this set has its index state dropped.
Sourcepub fn tile_count(&self) -> usize
pub fn tile_count(&self) -> usize
Total number of indexed tiles across all layers and zoom levels.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Total number of indexed symbol entries across all tiles and layers.
Trait Implementations§
Source§impl Clone for CrossTileSymbolIndex
impl Clone for CrossTileSymbolIndex
Source§fn clone(&self) -> CrossTileSymbolIndex
fn clone(&self) -> CrossTileSymbolIndex
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more