pub struct Quantizer { /* private fields */ }Expand description
Rounds float polygons onto the integer grid, keeping a valid polygon valid.
use geo_types::coord;
use map_tile_toolkit::Quantizer;
let mut quantizer = Quantizer::new();
let exterior = [coord! { x: 0.2, y: 0.1 }, coord! { x: 9.7, y: 0.4 }, coord! { x: 5.1, y: 8.6 }];
let rounded = quantizer.polygon([exterior]).unwrap();
let polygons: Vec<Vec<&[_]>> = rounded.polygons().map(Iterator::collect).collect();
assert_eq!(polygons, [[&[coord! { x: 0, y: 0 }, coord! { x: 10, y: 0 }, coord! { x: 5, y: 9 }][..]]]);Implementations§
Source§impl Quantizer
impl Quantizer
Sourcepub fn polygon<R>(&mut self, rings: R) -> Result<Quantized<'_>, TileError>
pub fn polygon<R>(&mut self, rings: R) -> Result<Quantized<'_>, TileError>
Rounds one valid polygon’s rings, exterior first, in grid units, into valid polygons.
§Errors
TileError::Overflow if a coordinate is not finite or rounds outside the i32 range.
Sourcepub fn make_valid<R>(&mut self, rings: R) -> Result<Quantized<'_>, TileError>
pub fn make_valid<R>(&mut self, rings: R) -> Result<Quantized<'_>, TileError>
Rounds any polygon’s rings, exterior first, in grid units, into valid polygons.
The area kept is what the exterior covers, minus what any hole covers.
§Errors
TileError::Overflow if a coordinate is not finite or rounds outside the i32 range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Quantizer
impl RefUnwindSafe for Quantizer
impl Send for Quantizer
impl Sync for Quantizer
impl Unpin for Quantizer
impl UnsafeUnpin for Quantizer
impl UnwindSafe for Quantizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more