#[repr(C)]pub struct BoundingBox {
pub west_longitude: f64,
pub south_latitude: f64,
pub east_longitude: f64,
pub north_latitude: f64,
}
Expand description
A BoundingBox
is a rectangular area on the globe specified by coordinates of
the southwest and northeast edges in decimal degrees.
Fields§
§west_longitude: f64
Longitude of the west side of the bounding box.
south_latitude: f64
Latitude of the south side of the bounding box.
east_longitude: f64
Longitude of the east side of the bounding box.
north_latitude: f64
Latitude of the north side of the bounding box.
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub const fn new(
west_longitude: f64,
south_latitude: f64,
east_longitude: f64,
north_latitude: f64,
) -> Self
pub const fn new( west_longitude: f64, south_latitude: f64, east_longitude: f64, north_latitude: f64, ) -> Self
Creates a BoundingBox
with the longitudes and latitudes of its sides.
§Example
use twitter_stream::builder::BoundingBox;
// Examples taken from Twitter's documentation.
BoundingBox::new(-122.75, 36.8, -121.75, 37.8); // San Francisco
BoundingBox::new(-74.0, 40.0, -73.0, 41.0); // New York City
Sourcepub fn unflatten_slice(slice: &[[f64; 4]]) -> &[Self]
pub fn unflatten_slice(slice: &[[f64; 4]]) -> &[Self]
Creates a slice of BoundingBox
-es from a slice of arrays of
[west_longitude, south_latitude, east_longitude, north_latitude]
.
§Examples
use twitter_stream::builder::BoundingBox;
#[derive(serde::Deserialize)]
struct Config {
locations: Vec<[f64; 4]>,
}
let config = r#"{"locations": [[-122.75, 36.8, -121.75, 37.8]]}"#;
let config: Config = serde_json::from_str(config).unwrap();
let locations = BoundingBox::unflatten_slice(&config.locations);
assert_eq!(locations, [BoundingBox::new(-122.75, 36.8, -121.75, 37.8)]);
Sourcepub fn flatten_slice(bboxes: &[Self]) -> &[[f64; 4]]
pub fn flatten_slice(bboxes: &[Self]) -> &[[f64; 4]]
Converts a slice of BoundingBox
-es into a slice of arrays of
[west_longitude, south_latitude, east_longitude, north_latitude]
.
Sourcepub fn unflatten_vec(vec: Vec<[f64; 4]>) -> Vec<Self>
pub fn unflatten_vec(vec: Vec<[f64; 4]>) -> Vec<Self>
Creates a vector of BoundingBox
-es from a vector of arrays of
[west_longitude, south_latitude, east_longitude, north_latitude]
.
§Examples
use twitter_stream::builder::BoundingBox;
#[derive(serde::Deserialize)]
struct Config {
locations: Vec<[f64; 4]>,
}
let config = r#"{"locations": [[-122.75, 36.8, -121.75, 37.8]]}"#;
let config: Config = serde_json::from_str(config).unwrap();
let locations = BoundingBox::unflatten_vec(config.locations);
assert_eq!(locations, [BoundingBox::new(-122.75, 36.8, -121.75, 37.8)]);
Trait Implementations§
Source§impl AsRef<BoundingBox> for [f64; 4]
impl AsRef<BoundingBox> for [f64; 4]
Source§fn as_ref(&self) -> &BoundingBox
fn as_ref(&self) -> &BoundingBox
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more