pub struct Bounds {
pub left: f64,
pub bottom: f64,
pub right: f64,
pub top: f64,
}
Fields§
§left: f64
§bottom: f64
§right: f64
§top: f64
Implementations§
source§impl Bounds
impl Bounds
sourcepub const MAX: Self = _
pub const MAX: Self = _
Create maximum bounds object in WGS84 space.
assert_eq!(
Bounds::MAX,
Bounds::new(-180.0, -90.0, 180.0, 90.0)
);
sourcepub const MAX_TILED: Self = _
pub const MAX_TILED: Self = _
Create maximum bounds object usable with vector tiles. See https://github.com/mapbox/tilejson-spec/tree/master/3.0.0#35-bounds
assert_eq!(
Bounds::MAX_TILED,
Bounds::new(-180.0, -85.05112877980659, 180.0, 85.0511287798066)
);
Trait Implementations§
source§impl AddAssign for Bounds
impl AddAssign for Bounds
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Combine another bounds into this one, resulting in an bounding box that encloses both.
let mut value = Bounds::new(1., 3., 7., 9.);
value += Bounds::new(2., 2., 8., 8.);
assert_eq!(value, Bounds::new(1., 2., 8., 9.))
source§impl Default for Bounds
impl Default for Bounds
source§fn default() -> Self
fn default() -> Self
Default bounds are set to [-180, -85.05112877980659, 180, 85.0511287798066]
See https://github.com/mapbox/tilejson-spec/tree/master/3.0.0#35-bounds
assert_eq!(Bounds::MAX_TILED, Bounds::default());
source§impl<'de> Deserialize<'de> for Bounds
impl<'de> Deserialize<'de> for Bounds
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Display for Bounds
impl Display for Bounds
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format Bounds struct as a comma-separated string. Accepts all precision formatting parameters as for floats.
let bounds = Bounds::new(-1.5, -2.5, 3.5, 4.5);
assert_eq!(bounds.to_string(), "-1.5,-2.5,3.5,4.5");
assert_eq!(format!("{bounds:.2}"), "-1.50,-2.50,3.50,4.50");
assert_eq!(Bounds::from_str(&bounds.to_string()).unwrap(), bounds);
source§impl FromStr for Bounds
impl FromStr for Bounds
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a string of four comma-separated values as a Bounds value,
same order as the Bounds::new
constructor. Extra spaces are ignored.
Example
let bounds = Bounds::from_str("-1.0, -2.0, 3, 4").unwrap();
assert_eq!(bounds, Bounds::new(-1.0, -2.0, 3.0, 4.0));
§type Err = ParseBoundsError
type Err = ParseBoundsError
source§impl PartialEq for Bounds
impl PartialEq for Bounds
source§impl TryFrom<&[f32]> for Bounds
impl TryFrom<&[f32]> for Bounds
source§fn try_from(value: &[f32]) -> Result<Self, Self::Error>
fn try_from(value: &[f32]) -> Result<Self, Self::Error>
Parse four f32
values as a Bounds value, same order as the Bounds::new
constructor.
assert_eq!(
Bounds::new(1., 2., 3., 4.),
Bounds::try_from(vec![1.0f32, 2.0f32, 3.0f32, 4.0f32].as_slice()).unwrap()
);
§type Error = ParseBoundsError
type Error = ParseBoundsError
source§impl TryFrom<&[f64]> for Bounds
impl TryFrom<&[f64]> for Bounds
source§fn try_from(value: &[f64]) -> Result<Self, Self::Error>
fn try_from(value: &[f64]) -> Result<Self, Self::Error>
Parse four f64
values as a Bounds value, same order as the Bounds::new
constructor.
assert_eq!(
Bounds::new(1., 2., 3., 4.),
Bounds::try_from(vec![1., 2., 3., 4.].as_slice()).unwrap()
);
§type Error = ParseBoundsError
type Error = ParseBoundsError
source§impl TryFrom<&[i32]> for Bounds
impl TryFrom<&[i32]> for Bounds
source§fn try_from(value: &[i32]) -> Result<Self, Self::Error>
fn try_from(value: &[i32]) -> Result<Self, Self::Error>
Parse four i32
values as a Bounds value, same order as the Bounds::new
constructor.
assert_eq!(
Bounds::new(1., 2., 3., 4.),
Bounds::try_from(vec![1, 2, 3, 4].as_slice()).unwrap()
);
§type Error = ParseBoundsError
type Error = ParseBoundsError
source§impl TryFrom<Vec<f64>> for Bounds
impl TryFrom<Vec<f64>> for Bounds
source§fn try_from(value: Vec<f64>) -> Result<Self, Self::Error>
fn try_from(value: Vec<f64>) -> Result<Self, Self::Error>
Parse four f64
values as a Bounds value, same order as the Bounds::new
constructor.
assert_eq!(
Bounds::new(1., 2., 3., 4.),
Bounds::try_from(vec![1., 2., 3., 4.]).unwrap()
);