Struct BBox

Source
pub struct BBox {
    pub west: f64,
    pub south: f64,
    pub east: f64,
    pub north: f64,
}
Expand description

Bounding box struct

Fields§

§west: f64

west/left boundary

§south: f64

south/bottom boundary

§east: f64

east/right boundary

§north: f64

north/top boundary

Implementations§

Source§

impl BBox

Source

pub fn new(west: f64, south: f64, east: f64, north: f64) -> Self

Create a new BBox

Source

pub fn world_planet() -> Self

Returns a bounding box that covers the entire world.

Source

pub fn world_web() -> Self

Returns a bounding box that covers the entire web mercator world.

Source

pub fn clamp_web(&self) -> Self

Source

pub fn clamp(&self, o: &BBox) -> Self

Source

pub fn geo_wrap(&self) -> Self

Source

pub fn is_antimeridian(&self) -> bool

Source

pub fn crosses_antimeridian(&self) -> bool

Returns true if the bounding box crosses the antimeridian (the 180-degree meridian).

Source

pub fn tuple(&self) -> (f64, f64, f64, f64)

Returns the bounding box as a tuple

Source

pub fn north(&self) -> f64

Returns the top/north boundary of the bounding box

Source

pub fn south(&self) -> f64

Returns the bottom/south boundary of the bounding box

Source

pub fn east(&self) -> f64

Returns the right/east boundary of the bounding box

Source

pub fn west(&self) -> f64

Returns the left/west boundary of the bounding box

Source

pub fn top(&self) -> f64

Returns the top/north boundary of the bounding box

Source

pub fn bottom(&self) -> f64

Returns the bottom/south boundary of the bounding box

Source

pub fn right(&self) -> f64

Returns the right/east boundary of the bounding box

Source

pub fn left(&self) -> f64

Returns the left/west boundary of the bounding box

Source

pub fn json_arr(&self) -> String

Returns the geojson tuple/array representation of the bounding box

Source

pub fn projwin_str(&self) -> String

Returns the gdal-ish string representation of the bounding box

Source

pub fn contains_lnglat(&self, lnglat: &LngLat) -> bool

Returns the center of the bounding box as a LngLat

Source

pub fn contains_tile(&self, tile: &Tile) -> bool

Returns true if the current instance contains the given Tile

Source

pub fn contains_bbox(&self, other: &BBox) -> bool

Returns true if the current instance contains the given BBox

Source

pub fn contains(&self, other: &BBoxContainable) -> bool

Returns true if the current instance contains the given BBoxContainable object.

Source

pub fn is_within(&self, other: &BBox) -> bool

Returns true if the current instance is within the given bounding box.

Source

pub fn intersects(&self, other: &BBox) -> bool

Returns true if the current instance intersects with the given bounding box.

Source

pub fn bboxes(&self) -> Vec<BBox>

Returns a vector of bounding boxes (BBox) associated with the current instance.

If the instance crosses the antimeridian (the 180-degree meridian), this function returns two BBox instances:

  • The first bounding box covers the area from the object’s western boundary to 180 degrees east.
  • The second bounding box covers the area from -180 degrees west to the object’s eastern boundary.

If the instance does not cross the antimeridian, the function returns a vector containing a single BBox that represents the current instance itself.

§Returns

Vec<BBox>: A vector containing one BBox if the instance does not cross the antimeridian, or two BBoxes if it does.

§Examples
use utiles_core::BBox;
let example = BBox::new(-10.0, -10.0, 10.0, 10.0);
let bboxes = example.bboxes();
assert_eq!(bboxes.len(), 1);

let bboxes_crosses = BBox::new(179.0, -89.0, -179.0, 89.0).bboxes();
assert_eq!(bboxes_crosses.len(), 2); // Split into two bounding boxes
Source

pub fn ul(&self) -> LngLat

Return upper left corner of bounding box as LngLat

Source

pub fn ur(&self) -> LngLat

Return upper right corner of bounding box as LngLat

Source

pub fn lr(&self) -> LngLat

Return lower right corner of bounding box as LngLat

Source

pub fn ll(&self) -> LngLat

Return lower left corner of bounding box as LngLat

Source

pub fn mbt_bounds(&self) -> String

Mbt metadata bounds string

Trait Implementations§

Source§

impl Clone for BBox

Source§

fn clone(&self) -> BBox

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BBox

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&String> for BBox

Source§

fn from(s: &String) -> Self

Converts to this type from the input type.
Source§

impl From<(f64, f64, f64, f64)> for BBox

Source§

fn from(bbox: (f64, f64, f64, f64)) -> Self

Converts to this type from the input type.
Source§

impl From<(i32, i32, i32, i32)> for BBox

Source§

fn from(bbox: (i32, i32, i32, i32)) -> Self

Converts to this type from the input type.
Source§

impl From<BBox> for (f64, f64, f64, f64)

Source§

fn from(bbox: BBox) -> Self

Converts to this type from the input type.
Source§

impl From<BBox> for BBoxTuple

Source§

fn from(bbox: BBox) -> Self

Converts to this type from the input type.
Source§

impl From<BBox> for WebBBox

Source§

fn from(bbox: BBox) -> Self

Converts to this type from the input type.
Source§

impl From<BBoxTuple> for BBox

Source§

fn from(tuple: BBoxTuple) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for BBox

Source§

fn eq(&self, other: &BBox) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BBox

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&str> for BBox

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for BBox

Source§

impl StructuralPartialEq for BBox

Auto Trait Implementations§

§

impl Freeze for BBox

§

impl RefUnwindSafe for BBox

§

impl Send for BBox

§

impl Sync for BBox

§

impl Unpin for BBox

§

impl UnwindSafe for BBox

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.