pub struct PolygonSlicerAll<V: PolyVertex = Coord<i32>, A = ()> { /* private fields */ }Expand description
Slices integer multipolygon features into every tile they reach, keeping original vertices.
The polygon counterpart to SlicerAll, and the all-tiles counterpart to
PolygonSlicerOne: for every tile a feature’s ring edges touch (its
edge tiles), the pieces are exactly what a PolygonSlicerOne bound to that tile yields for each
of the feature’s polygons, in order. Generic over the PolyVertex type V (default
Coord<i32>) and the per-feature attribute A (default ()).
Reading back is per feature (iter_features), then per edge tile, polygon,
and ring. Output rings keep the winding of the input rings they come from (see
signed_area_2x to normalize it first).
The cost is proportional to the routing work (the edge tiles) plus the ring edges’ crossings of
tile-row center lines — independent of ring length per tile. All storage is flat and reused:
clear keeps every buffer’s capacity, so one slicer per worker, cleared between
features, stops allocating once warmed up.
Implementations§
Source§impl<V: PolyVertex, A> PolygonSlicerAll<V, A>
impl<V: PolyVertex, A> PolygonSlicerAll<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
(same coordinate model as SlicerAll).
§Errors
TileError::InvalidExtentifextentis0or greater thani32::MAX.TileError::BufferTooLargeifbufferis not strictly less than half theextent.
Sourcepub fn add_feature_with<P>(
&mut self,
polygons: P,
attr: A,
) -> Result<&mut Self, TileError>
pub fn add_feature_with<P>( &mut self, polygons: P, attr: A, ) -> Result<&mut Self, TileError>
Add one multipolygon feature carrying attr, slicing it into every tile it reaches. Chainable.
polygons yields each polygon as its rings — exterior first, then holes — each a vertex slice,
open or closed (a repeated first/last vertex is fine), e.g. [[&exterior[..], &hole[..]]].
Rings with fewer than 3 distinct vertices are ignored, and so is a polygon whose exterior is.
The feature (and attr) is recorded only if some tile receives geometry.
When A = (), prefer add_feature.
Atomic: on error nothing is recorded, so the slicer stays usable — skip the input and go on.
§Errors
TileError::TooManyTilesif the feature’s edges touch more than 2^25 tiles in total, counting each row an edge crosses without touching a tile as one (one budget of visits per feature; covered tiles are free).TileError::Overflowif coordinate math overflowsi32(geometry too near its limits).TileError::OutputTooLargeif the feature’s pieces would exceed 2^28 vertices (only rings winding around tiles many times, or many overlapping polygons, get there).TileError::GeometryTooLargeif the geometry exceeds theu32indexing of the storage.
Sourcepub fn iter_features(
&self,
) -> impl Iterator<Item = PolygonFeatureView<'_, V, A>>
pub fn iter_features( &self, ) -> impl Iterator<Item = PolygonFeatureView<'_, V, A>>
Iterate the recorded features, in the order added.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Discard everything recorded, keeping the extent/buffer config and every buffer’s capacity.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Release the memory not needed for what is recorded, including the working memory a large
feature left behind: clear keeps every buffer’s capacity, so after an outlier
a long-lived slicer would otherwise hold its peak forever.
Source§impl<V: PolyVertex> PolygonSlicerAll<V, ()>
impl<V: PolyVertex> PolygonSlicerAll<V, ()>
Sourcepub fn add_feature<P>(&mut self, polygons: P) -> Result<&mut Self, TileError>
pub fn add_feature<P>(&mut self, polygons: P) -> Result<&mut Self, TileError>
Add one multipolygon feature with no attribute — shorthand for
add_feature_with(polygons, ()). Available only when A = ().
§Errors
As in add_feature_with.