[][src]Struct twitter_stream::builder::BoundingBox

#[repr(C)]pub struct BoundingBox {
    pub west_longitude: f64,
    pub south_latitude: f64,
    pub east_longitude: f64,
    pub north_latitude: f64,
}

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

impl BoundingBox[src]

pub const fn new(
    west_longitude: f64,
    south_latitude: f64,
    east_longitude: f64,
    north_latitude: f64
) -> Self
[src]

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

pub fn unflatten_slice(slice: &[[f64; 4]]) -> &[Self][src]

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)]);

pub fn flatten_slice(bboxes: &[Self]) -> &[[f64; 4]][src]

Converts a slice of BoundingBox-es into a slice of arrays of [west_longitude, south_latitude, east_longitude, north_latitude].

pub fn unflatten_vec(vec: Vec<[f64; 4]>) -> Vec<Self>[src]

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)]);

pub fn flatten_vec(vec: Vec<Self>) -> Vec<[f64; 4]>[src]

Converts a vector of BoundingBox-es into a vector of arrays of [west_longitude, south_latitude, east_longitude, north_latitude].

Trait Implementations

impl AsRef<[f64; 4]> for BoundingBox[src]

impl Clone for BoundingBox[src]

impl Copy for BoundingBox[src]

impl Debug for BoundingBox[src]

impl From<[f64; 4]> for BoundingBox[src]

impl From<((f64, f64), (f64, f64))> for BoundingBox[src]

pub fn from(
    ((west_longitude, south_latitude), (east_longitude, north_latitude)): ((f64, f64), (f64, f64))
) -> Self
[src]

Creates a BoundingBox with two (longitude, latitude) pairs.

The first argument specifies the southwest edge and the latter specifies the northeast edge.

impl From<(f64, f64, f64, f64)> for BoundingBox[src]

impl PartialEq<BoundingBox> for BoundingBox[src]

impl StructuralPartialEq for BoundingBox[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> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,