pub struct SlicerOne<V: Vertex = Coord<i32>, A = ()> { /* private fields */ }Expand description
Slices integer polylines into pieces for one fixed tile, accumulating only that tile.
The single-tile counterpart to SlicerAll: add_feature /
add_feature_with work exactly the same, but each polyline is clipped
only to this slicer’s tile. Because there is a single tile, the read API skips the
tile level — iter_features yields the features directly.
Generic over the Vertex type V (defaults to Coord<i32>) and the per-feature attribute
type A (defaults to ()); see SlicerAll for both axes.
Implementations§
Source§impl<V: Vertex, A> SlicerOne<V, A>
impl<V: Vertex, A> SlicerOne<V, A>
Sourcepub fn new(extent: u32, buffer: u16, tile: TileId) -> Result<Self, TileError>
pub fn new(extent: u32, buffer: u16, tile: TileId) -> Result<Self, TileError>
Create a slicer bound to tile, with the given tile side / per-tile output resolution extent
and buffer (see SlicerAll::new for the coordinate model).
§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>
pub fn add_feature_with<P: AsRef<[V]>>( &mut self, polyline: P, attr: A, ) -> Result<&mut Self, TileError>
Add polyline as an independent feature carrying attr, clipped to this slicer’s
tile. Chainable. The feature (and its attribute) is recorded only if something
of polyline lands in the tile; otherwise attr is dropped. Reach it back through
FeatureView::attr.
When A = (), prefer add_feature.
Atomic: the polyline is fully sliced first, so on error the accumulator is left unchanged.
§Errors
TileError::Overflow if the tile’s box or a kept vertex overflows i32.
Sourcepub fn iter_features(&self) -> impl Iterator<Item = FeatureView<'_, V, A>>
pub fn iter_features(&self) -> impl Iterator<Item = FeatureView<'_, V, A>>
Iterate this tile’s features, in the order they were first added. Each FeatureView exposes
that feature’s clipped polylines and its attr.
Source§impl<V: Vertex> SlicerOne<V, ()>
impl<V: Vertex> SlicerOne<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::Overflow if the tile’s box or a kept vertex overflows i32.