pub struct TileRect {
pub zoom: u8,
pub min_x: u32,
pub min_y: u32,
pub max_x: u32,
pub max_y: u32,
}
Expand description
A rectangular region in tile coordinate space.
Represents a rectangle defined by zoom level and tile coordinates.
The rectangle is inclusive of both min and max coordinates.
Use append_rect
to merge rectangles without overlapping.
§Examples
let rect = TileRect::new(10, 0, 0, 255, 255);
assert_eq!(rect.size(), 256 * 256);
Fields§
§zoom: u8
The zoom level of the tiles
min_x: u32
The minimum X coordinate (inclusive)
min_y: u32
The minimum Y coordinate (inclusive)
max_x: u32
The maximum X coordinate (inclusive)
max_y: u32
The maximum Y coordinate (inclusive)
Implementations§
Source§impl TileRect
impl TileRect
Sourcepub fn new(zoom: u8, min_x: u32, min_y: u32, max_x: u32, max_y: u32) -> Self
pub fn new(zoom: u8, min_x: u32, min_y: u32, max_x: u32, max_y: u32) -> Self
Creates a new TileRect
with the specified coordinates.
§Arguments
zoom
- The zoom levelmin_x
- The minimum X coordinate (inclusive)min_y
- The minimum Y coordinate (inclusive)max_x
- The maximum X coordinate (inclusive)max_y
- The maximum Y coordinate (inclusive)
§Panics
Panics if min_x > max_x
or min_y > max_y
.
§Examples
let rect = TileRect::new(0, 0, 0, 1, 1);
assert_eq!(rect.size(), 4);
Sourcepub fn is_overlapping(&self, other: &Self) -> bool
pub fn is_overlapping(&self, other: &Self) -> bool
Checks if two rectangles overlap.
Two rectangles overlap if
- they share the same zoom level and
- their coordinate ranges intersect in both X and Y dimensions.
§Examples
let rect1 = TileRect::new(0, 0, 0, 1, 1);
let rect2 = TileRect::new(0, 1, 1, 2, 2);
assert!(rect1.is_overlapping(&rect2));
let rect3 = TileRect::new(0, 2, 2, 3, 3);
assert!(!rect1.is_overlapping(&rect3));
Trait Implementations§
impl Copy for TileRect
impl StructuralPartialEq for TileRect
Auto Trait Implementations§
impl Freeze for TileRect
impl RefUnwindSafe for TileRect
impl Send for TileRect
impl Sync for TileRect
impl Unpin for TileRect
impl UnwindSafe for TileRect
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