Skip to main content

SlicerAll

Struct SlicerAll 

Source
pub struct SlicerAll<V: Vertex = Coord<i32>, A = ()> { /* private fields */ }
Expand description

Slices integer polylines into per-tile pieces on an integer grid, accumulating every tile each polyline touches.

Generic over two independent axes:

  • the Vertex type V (defaults to Coord<i32>) — plain coordinates or payload-carrying vertices (e.g. a per-vertex M value via Measured); the payload rides through slicing unchanged;
  • a per-feature attribute type A (defaults to ()) — an id, a property map, anything you want re-associated with each sliced piece. With A = () the attribute channel is a zero-sized type and costs nothing.

The two are orthogonal: SlicerAll<Measured<M>, Attrs> carries per-vertex M and per-feature attributes without either taxing the other. Add a polyline with no attribute via add_feature (only when A = ()), or with one via add_feature_with; read them back with iter_tiles, reaching each piece’s attribute through FeatureView::attr. A feature split across tiles has its attribute duplicated onto every tile it touches (so A must be Clone).

The slicer never panics: bad input (an oversized polyline, or coordinates that overflow the tile math) yields an TileError instead.

Implementations§

Source§

impl<V: Vertex, A> SlicerAll<V, A>

Source

pub fn new(extent: u32, buffer: u16) -> Result<Self, TileError>

Create a slicer with the given tile side / per-tile output resolution extent and buffer.

Coordinates are integers in tile space: a vertex belongs to tile x.div_euclid(extent) and is emitted at x − tile·extent ∈ [0, extent). Project / simplify / affine-scale float source data into this space (e.g. with geo) before slicing.

§Errors
Source

pub fn extent(&self) -> u32

The tile side / per-tile output resolution: kept vertices land in 0..extent.

Source

pub fn buffer(&self) -> u16

The buffer kept around every tile, in tile-space units.

Source

pub fn add_feature_with<P: AsRef<[V]>>( &mut self, polyline: P, attr: A, ) -> Result<&mut Self, TileError>
where A: Clone,

Add polyline as an independent feature carrying attr: slice it into every tile it touches, storing its runs as a fresh feature in each and duplicating attr onto every tile it reaches. Chainable. Reach the attribute back through FeatureView::attr.

When A = (), prefer add_feature, which passes the unit attribute for you.

Atomic: on error the pieces written so far are rolled back, so a failed polyline leaves the accumulator unchanged and usable — safe to skip the offending input and keep adding. (Errors only arise for pathological input: an oversized polyline, an adversarial spread, or coordinates near the i32 limits.)

§Errors

TileError::PolylineTooLarge, TileError::TooManyTiles, or TileError::Overflow.

Source

pub fn iter_tiles(&self) -> impl Iterator<Item = TileView<'_, V, A>>

Iterate the touched tiles, ordered by TileId, borrowing so the accumulator can keep growing afterwards. Each TileView exposes that tile’s features.

Source

pub fn len(&self) -> usize

Number of tiles the accumulator has touched.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been accumulated yet.

Source

pub fn clear(&mut self)

Discard everything accumulated so far, keeping the extent/buffer config.

Source§

impl<V: Vertex> SlicerAll<V, ()>

Source

pub fn add_feature<P: AsRef<[V]>>( &mut self, polyline: P, ) -> Result<&mut Self, TileError>

Add polyline as an independent feature with no attribute — shorthand for add_feature_with(polyline, ()). Available only when A = ().

§Errors

TileError::PolylineTooLarge, TileError::TooManyTiles, or TileError::Overflow.

Trait Implementations§

Source§

impl<V: Clone + Vertex, A: Clone> Clone for SlicerAll<V, A>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug + Vertex, A: Debug> Debug for SlicerAll<V, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Eq + Vertex, A: Eq> Eq for SlicerAll<V, A>

Source§

impl<V: PartialEq + Vertex, A: PartialEq> PartialEq for SlicerAll<V, A>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<V: PartialEq + Vertex, A: PartialEq> StructuralPartialEq for SlicerAll<V, A>

Auto Trait Implementations§

§

impl<V, A> Freeze for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: Freeze, Option<A>: Freeze,

§

impl<V, A> RefUnwindSafe for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: RefUnwindSafe, Option<A>: RefUnwindSafe,

§

impl<V, A> Send for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: Send, Option<A>: Send,

§

impl<V, A> Sync for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: Sync, Option<A>: Sync,

§

impl<V, A> Unpin for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: Unpin, Option<A>: Unpin,

§

impl<V, A> UnsafeUnpin for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: UnsafeUnpin, Option<A>: UnsafeUnpin,

§

impl<V, A> UnwindSafe for SlicerAll<V, A>
where Vec<TileBuf<V, A>>: UnwindSafe, Option<A>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.