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
VertextypeV(defaults toCoord<i32>) — plain coordinates or payload-carrying vertices (e.g. a per-vertex M value viaMeasured); 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. WithA = ()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>
impl<V: Vertex, A> SlicerAll<V, A>
Sourcepub fn new(extent: u32, buffer: u16) -> Result<Self, TileError>
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
TileError::InvalidExtentifextentis0or greater thani32::MAX.TileError::BufferTooLargeifbufferis not strictly less than half theextent.
Sourcepub fn extent(&self) -> u32
pub fn extent(&self) -> u32
The tile side / per-tile output resolution: kept vertices land in 0..extent.
Sourcepub fn add_feature_with<P: AsRef<[V]>>(
&mut self,
polyline: P,
attr: A,
) -> Result<&mut Self, TileError>where
A: Clone,
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::GeometryTooLarge, TileError::TooManyTiles, or TileError::Overflow.
Sourcepub fn iter_tiles(&self) -> impl Iterator<Item = TileView<'_, V, A>>
pub fn iter_tiles(&self) -> impl Iterator<Item = TileView<'_, V, A>>
Source§impl<V: Vertex> SlicerAll<V, ()>
impl<V: Vertex> SlicerAll<V, ()>
Sourcepub fn add_feature<P: AsRef<[V]>>(
&mut self,
polyline: P,
) -> Result<&mut Self, TileError>
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::GeometryTooLarge, TileError::TooManyTiles, or TileError::Overflow.