[][src]Struct vadeen_osm::geo::Boundary

pub struct Boundary {
    pub min: Coordinate,
    pub max: Coordinate,
    pub freeze: bool,
}

Represents coordinate boundary, i.e. min and max latitude and longitude.

Examples

// Default creates boundaries cover the whole world
let bounds = Boundary::default();

assert_eq!(bounds.min.lat(), -90.0);
assert_eq!(bounds.min.lon(), -180.0);
assert_eq!(bounds.max.lat(), 90.0);
assert_eq!(bounds.max.lon(), 180.0);

// Inverted boundary is same as default, but with max as min and min as max.
// Useful when the boundary is intended to be dynamically expanded.
let mut bounds = Boundary::inverted();

assert_eq!(bounds.min.lat(), 90.0);
assert_eq!(bounds.min.lon(), 180.0);
assert_eq!(bounds.max.lat(), -90.0);
assert_eq!(bounds.max.lon(), -180.0);

bounds.expand((10.0, 20.0).into());
bounds.expand((30.0, 40.0).into());

assert_eq!(bounds.min.lat(), 10.0);
assert_eq!(bounds.min.lon(), 20.0);
assert_eq!(bounds.max.lat(), 30.0);
assert_eq!(bounds.max.lon(), 40.0);

Fields

min: Coordinatemax: Coordinatefreeze: bool

Methods

impl Boundary[src]

pub fn inverted() -> Self[src]

Same as default() but inverted so min contains max and max contains min. Used when a boundary are intended to be expanded by coordinates.

pub fn expand(&mut self, c: Coordinate)[src]

Expand boundary if necessary to include a coordinate.

Trait Implementations

impl Clone for Boundary[src]

impl Debug for Boundary[src]

impl Default for Boundary[src]

impl Eq for Boundary[src]

impl PartialEq<Boundary> for Boundary[src]

impl StructuralEq for Boundary[src]

impl StructuralPartialEq for Boundary[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.