pub struct BBox<T = f64> {
pub left: T,
pub bottom: T,
pub right: T,
pub top: T,
}Expand description
§Bounding Box
§Description
A Bounding Box ensures a min-max range of values
The order is (left, bottom, right, top) when storing as a flattened array.
If WM, then the projection is lon-lat. If S2, then the projection is s-t
Defaults to f64 as the base type.
Implements MValueCompatible
§Usage
§From/To
§Any Type BBox
BBox::new: Creates a new BBoxBBox::point_overlap: Checks if a point is within the BBoxBBox::merge: Merges another bounding box with this oneBBox::merge_in_place: Merges in place another bounding box with this oneBBox::overlap: Checks if another bounding box overlaps with this oneBBox::clip: Clips the bounding box along an axisBBox::inside: Checks if this bounding box is inside anotherBBox::area: Returns the area of the bounding box
§f64 Type BBox
Note that all the input geometry uses the GetXY trait.
BBox::from_point: Creates a new BBox from a pointBBox::from_linestring: Creates a new BBox from a linestringBBox::from_multi_linestring: Creates a new BBox from a multi-linestringBBox::from_polygon: Creates a new BBox from a polygonBBox::from_multi_polygon: Creates a new BBox from a multi-polygonBBox::extend_from_point: Extends the bounding box with a pointBBox::from_uv_zoom: Creates a new BBox from zoom-uv coordinatesBBox::from_st_zoom: Creates a new BBox from zoom-st coordinates
Fields§
§left: Tleft most longitude (WM) or S (S2)
bottom: Tbottom most latitude (WM) or T (S2)
right: Tright most longitude (WM) or T (S2)
top: Ttop most latitude (WM) or S (S2)
Implementations§
Source§impl<T> BBox<T>
impl<T> BBox<T>
Sourcepub fn point_overlap<P: GetXY>(&self, point: &P) -> bool
pub fn point_overlap<P: GetXY>(&self, point: &P) -> bool
Checks if a point is within the BBox
Sourcepub fn merge(&self, other: &Self) -> Selfwhere
T: PartialOrd + Copy,
pub fn merge(&self, other: &Self) -> Selfwhere
T: PartialOrd + Copy,
Merges another bounding box with this one
Sourcepub fn merge_in_place(&mut self, other: &Self)where
T: PartialOrd + Copy,
pub fn merge_in_place(&mut self, other: &Self)where
T: PartialOrd + Copy,
Merges in place another bounding box with this one
Sourcepub fn overlap(&self, other: &BBox<T>) -> Option<BBox<T>>where
T: PartialOrd + Copy,
pub fn overlap(&self, other: &BBox<T>) -> Option<BBox<T>>where
T: PartialOrd + Copy,
Checks if another bounding box overlaps with this one and returns the overlap
Sourcepub fn clip(&self, axis: Axis, k1: T, k2: T) -> BBox<T>where
T: PartialOrd + Copy,
pub fn clip(&self, axis: Axis, k1: T, k2: T) -> BBox<T>where
T: PartialOrd + Copy,
Clips the bounding box along an axis
Source§impl BBox<f64>
impl BBox<f64>
Sourcepub fn from_point<P: GetXY>(point: &P) -> Self
pub fn from_point<P: GetXY>(point: &P) -> Self
Creates a new BBox from a point
Sourcepub fn from_linestring<P: GetXY>(line: &[P]) -> Self
pub fn from_linestring<P: GetXY>(line: &[P]) -> Self
Creates a new BBox from a linestring
Sourcepub fn from_multi_linestring<P: GetXY>(lines: &[Vec<P>]) -> Self
pub fn from_multi_linestring<P: GetXY>(lines: &[Vec<P>]) -> Self
Creates a new BBox from a multi-linestring
Sourcepub fn from_polygon<P: GetXY>(polygon: &[Vec<P>]) -> Self
pub fn from_polygon<P: GetXY>(polygon: &[Vec<P>]) -> Self
Creates a new BBox from a polygon
Sourcepub fn from_multi_polygon<P: GetXY>(polygons: &[Vec<Vec<P>>]) -> Self
pub fn from_multi_polygon<P: GetXY>(polygons: &[Vec<Vec<P>>]) -> Self
Creates a new BBox from a multi-polygon
Sourcepub fn extend_from_point<P: GetXY>(&mut self, point: &P)
pub fn extend_from_point<P: GetXY>(&mut self, point: &P)
Extends the bounding box with a point
Sourcepub fn from_uv_zoom(u: f64, v: f64, zoom: u8) -> Self
pub fn from_uv_zoom(u: f64, v: f64, zoom: u8) -> Self
Creates a new BBox from zoom-uv coordinates
Sourcepub fn from_st_zoom(s: f64, t: f64, zoom: u8) -> Self
pub fn from_st_zoom(s: f64, t: f64, zoom: u8) -> Self
Creates a new BBox from zoom-st coordinates