sphereql_layout/traits.rs
1use sphereql_core::SphericalPoint;
2
3use crate::types::LayoutResult;
4
5/// Projects an item from its native representation to a position on S².
6pub trait DimensionMapper: Send + Sync {
7 type Item;
8 /// Maps `item` to a spherical position.
9 fn map(&self, item: &Self::Item) -> SphericalPoint;
10}
11
12/// A layout algorithm that assigns positions on S² to a set of items.
13pub trait LayoutStrategy<T>: Send + Sync {
14 /// Computes positions for all `items` using `mapper` to derive their natural positions.
15 fn layout(&self, items: &[T], mapper: &dyn DimensionMapper<Item = T>) -> LayoutResult<T>;
16}