Skip to main content

PositionSource

Trait PositionSource 

Source
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§

Source

fn feature_count(&self) -> usize

How many features this source addresses. Ids are 0..feature_count().

Source

fn position(&self, id: u32) -> WorldPos

The anchor of feature id in world space, z left at 0.0.

Out-of-range ids must return a non-finite position rather than panicking — a stale id from a previous frame is a normal event and the engine filters non-finite positions out before any work.

Source

fn kind(&self) -> &'static str

Short tag for state_json / diagnostics ("mercator", "layout", …).

Provided Methods§

Source

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.

Source

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.

Source

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".

Implementors§