pub struct PolygonMosaic<V: Vertex = Coord<i32>> { /* private fields */ }Expand description
Reassembles tiled polygon features back into whole rings as tiles are added — the accumulating inverse of the polygon slicer.
Generic over the Vertex type V (defaults to Coord<i32>). Needs the extent and
buffer the tiles were sliced at, so it can re-derive each tile’s buffered box and recognise the
synthetic clip-boundary corners the slicer injected (see the module docs). Reassembly is by
directed edge, so each ring comes back with its original orientation; a payload-carrying vertex
additionally makes payload Conflicts meaningful.
Implementations§
Source§impl<V: Vertex> PolygonMosaic<V>
impl<V: Vertex> PolygonMosaic<V>
Sourcepub fn new(extent: u32, buffer: u16) -> Result<Self, TileError>
pub fn new(extent: u32, buffer: u16) -> Result<Self, TileError>
Create an empty polygon mosaic for tiles sliced at extent with buffer.
§Errors
TileError::InvalidExtentifextentis0, orextent + bufferexceedsi32::MAX.TileError::BufferTooLargeifbufferis not strictly less than half theextent.
Sourcepub fn add<L: AsRef<[V]>>(
&mut self,
tile: TileId,
rings: &[L],
) -> Result<(), TileError>
pub fn add<L: AsRef<[V]>>( &mut self, tile: TileId, rings: &[L], ) -> Result<(), TileError>
Add tile’s rings (in its local frame) to the mosaic. rings is anything sliceable to [V]
(e.g. &[&[V]] collected from a tile’s polygon features — exterior and hole rings alike, in any
order). Each ring may be given open or closed. Re-adding a tile replaces its contents. A tile
that contributes only synthetic geometry (a solid interior fill) records nothing.
The synthetic clip-boundary corners are dropped geometrically before anything is indexed, so
they never enter the edge map and can raise no Conflict.
§Errors
TileError::Conflictif the tile disagrees with already-added tiles on a shared border edge. The mosaic is unchanged.TileError::Overflowif the tile’s box or a vertex overflowsi32in the global frame.
Sourcepub fn purge(&mut self, tile: TileId) -> bool
pub fn purge(&mut self, tile: TileId) -> bool
Remove tile and all geometry it contributed. Returns whether the tile was present.
Sourcepub fn iter_features(&self) -> impl Iterator<Item = Vec<V>>
pub fn iter_features(&self) -> impl Iterator<Item = Vec<V>>
Iterate every reassembled ring — geometry stitched across tile borders into maximal chains, in the global frame. A single iterator over the whole mosaic; deterministic order.