pub struct BoundingBox { /* private fields */ }Expand description
An axis-aligned bounding box in WGS84 coordinates.
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub fn new(minx: f32, miny: f32, maxx: f32, maxy: f32) -> Result<Self, GeoError>
pub fn new(minx: f32, miny: f32, maxx: f32, maxy: f32) -> Result<Self, GeoError>
Constructs a BoundingBox from raw coordinate values.
Validates each coordinate individually, then checks that the box is
non-degenerate (minx < maxx and miny < maxy).
§Errors
| Variant | Condition |
|---|---|
GeoError::NonFiniteCoordinate | Any value is NaN or infinite |
GeoError::LongitudeOutOfRange | minx or maxx outside [-180, 180] |
GeoError::LatitudeOutOfRange | miny or maxy outside [-90, 90] |
GeoError::DegenerateBbox | minx >= maxx or miny >= maxy |
Sourcepub fn contains(&self, lon: Longitude, lat: Latitude) -> bool
pub fn contains(&self, lon: Longitude, lat: Latitude) -> bool
Returns true if the given coordinate falls within or on the boundary
of this bounding box.
Sourcepub fn intersects(&self, other: &BoundingBox) -> bool
pub fn intersects(&self, other: &BoundingBox) -> bool
Returns true if this bounding box overlaps with other (including
edge-touching).
Trait Implementations§
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoundingBox
impl Debug for BoundingBox
Source§impl PartialEq for BoundingBox
impl PartialEq for BoundingBox
impl Copy for BoundingBox
impl StructuralPartialEq for BoundingBox
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnsafeUnpin for BoundingBox
impl UnwindSafe for BoundingBox
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