Skip to main content

PolygonSlicerAll

Struct PolygonSlicerAll 

Source
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>

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 (same coordinate model as SlicerAll).

§Errors
Source

pub fn extent(&self) -> u32

The tile side / per-tile output resolution.

Source

pub fn buffer(&self) -> u16

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

Source

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::TooManyTiles if 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::Overflow if coordinate math overflows i32 (geometry too near its limits).
  • TileError::OutputTooLarge if the feature’s pieces would exceed 2^28 vertices (only rings winding around tiles many times, or many overlapping polygons, get there).
  • TileError::GeometryTooLarge if the geometry exceeds the u32 indexing of the storage.
Source

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

Iterate the recorded features, in the order added.

Source

pub fn len(&self) -> usize

Number of features recorded.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been recorded yet.

Source

pub fn clear(&mut self)

Discard everything recorded, keeping the extent/buffer config and every buffer’s capacity.

Source

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, ()>

Source

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.

Trait Implementations§

Source§

impl<V: Clone + PolyVertex, A: Clone> Clone for PolygonSlicerAll<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 + PolyVertex, A: Debug> Debug for PolygonSlicerAll<V, A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V, A> Freeze for PolygonSlicerAll<V, A>
where Pieces<V>: Freeze, Vec<FeatureEntry<A>>: Freeze, Input<V>: Freeze,

§

impl<V, A> RefUnwindSafe for PolygonSlicerAll<V, A>
where Pieces<V>: RefUnwindSafe, Vec<FeatureEntry<A>>: RefUnwindSafe, Input<V>: RefUnwindSafe,

§

impl<V, A> Send for PolygonSlicerAll<V, A>
where Pieces<V>: Send, Vec<FeatureEntry<A>>: Send, Input<V>: Send,

§

impl<V, A> Sync for PolygonSlicerAll<V, A>
where Pieces<V>: Sync, Vec<FeatureEntry<A>>: Sync, Input<V>: Sync,

§

impl<V, A> Unpin for PolygonSlicerAll<V, A>
where Pieces<V>: Unpin, Vec<FeatureEntry<A>>: Unpin, Input<V>: Unpin,

§

impl<V, A> UnsafeUnpin for PolygonSlicerAll<V, A>
where Pieces<V>: UnsafeUnpin, Vec<FeatureEntry<A>>: UnsafeUnpin, Input<V>: UnsafeUnpin,

§

impl<V, A> UnwindSafe for PolygonSlicerAll<V, A>
where Pieces<V>: UnwindSafe, Vec<FeatureEntry<A>>: UnwindSafe, Input<V>: 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.