pub trait PositionSource: Debug {
// Required methods
fn feature_count(&self) -> usize;
fn position(&self, id: u32) -> WorldPos;
fn kind(&self) -> &'static str;
// Provided methods
fn bounds(&self, id: u32) -> WorldAabb { ... }
fn positions(&self, ids: &[u32], out: &mut Vec<WorldPos>) { ... }
fn generation(&self) -> u64 { ... }
}Expand description
Where is feature id?
The single seam between “this is a map” and “this is a graph”. A road’s position comes from Mercator; a node’s comes from a force layout; an overlay glyph’s is already in logical pixels. Downstream — culling, tessellation, label collision, picking — cannot tell which it got.
Required Methods§
Sourcefn feature_count(&self) -> usize
fn feature_count(&self) -> usize
How many features this source addresses. Ids are 0..feature_count().
Provided Methods§
Sourcefn bounds(&self, id: u32) -> WorldAabb
fn bounds(&self, id: u32) -> WorldAabb
The world-space extent of feature id. Point features keep the default.
A road, a building footprint or a cluster hull overrides it — that box is
what the culler and the Hierarchy index.
Sourcefn positions(&self, ids: &[u32], out: &mut Vec<WorldPos>)
fn positions(&self, ids: &[u32], out: &mut Vec<WorldPos>)
Batch projection — the hot path. Overriding it is how a columnar source (Arrow, a GPU-resident buffer) avoids a virtual call per feature.
Sourcefn generation(&self) -> u64
fn generation(&self) -> u64
A generation counter. Bump it whenever positions move, so caches (cull index, pick index, screen grids) know to rebuild. A static source returns a constant; a live force layout returns its iteration number.
This is the whole reason Layout is a distinct type from Identity:
identical arithmetic, different invalidation.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".