Struct geohashrust::BoundingBox
[−]
[src]
pub struct BoundingBox { pub min_lat: f64, pub max_lat: f64, pub min_lon: f64, pub max_lon: f64, }
A bounding box composed by 2 geolocations
Fields
min_lat: f64
max_lat: f64
min_lon: f64
max_lon: f64
Methods
impl BoundingBox
[src]
fn new() -> BoundingBox
Create a new BoudingBox
with default values
Example
let b=geohashrust::BoundingBox::new(); assert!(b.min_lat==0.0); assert!(b.min_lon==0.0); assert!(b.max_lat==0.0); assert!(b.max_lon==0.0);
fn from_coordinates(
minlat: f64,
maxlat: f64,
minlon: f64,
maxlon: f64
) -> BoundingBox
minlat: f64,
maxlat: f64,
minlon: f64,
maxlon: f64
) -> BoundingBox
Create a new BoudingBox
with 4 coordinates
Example
let b=geohashrust::BoundingBox::from_coordinates(34.0, 12.0, 78.0, 56.0); assert!(b.min_lat==12.0); assert!(b.min_lon==56.0); assert!(b.max_lat==34.0); assert!(b.max_lon==78.0);
fn from_geolocations(p1: &GeoLocation, p2: &GeoLocation) -> BoundingBox
Creates a new BoundingBox
with 2 GeoLocations
Example
let box1=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude:23.0, longitude:89.0, }, &geohashrust::GeoLocation{ latitude:67.0, longitude:45.0, }, ); assert!(box1.min_lat==23.0); assert!(box1.min_lon==45.0); assert!(box1.max_lat==67.0); assert!(box1.max_lon==89.0);
fn merged(one: &BoundingBox, other: &BoundingBox) -> BoundingBox
Creates a new BoundingBox
with the merge of 2 BoundingBoxes
Example
let box1=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); let box2=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 123.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 145.0, }, ); let box3=geohashrust::BoundingBox::merged(&box1, &box2); assert_eq!(box3.min_lat, 23.0); assert_eq!(box3.min_lon, 45.0); assert_eq!(box3.max_lat, 123.0); assert_eq!(box3.max_lon, 145.0);
fn center(&self) -> GeoLocation
Get the center point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.center().latitude, 45.0); assert_eq!(b.center().longitude, 67.0);
fn top_left(&self) -> GeoLocation
Get the top-left point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.top_left().latitude, 67.0); assert_eq!(b.top_left().longitude, 45.0);
fn top_right(&self) -> GeoLocation
Get the top-right point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.top_right().latitude, 67.0); assert_eq!(b.top_right().longitude, 89.0);
fn bottom_left(&self) -> GeoLocation
Get the bottom-left point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.bottom_left().latitude, 23.0); assert_eq!(b.bottom_left().longitude, 45.0);
fn bottom_right(&self) -> GeoLocation
Get the bottom-right point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.bottom_right().latitude, 23.0); assert_eq!(b.bottom_right().longitude, 89.0);
fn latitude_range(&self) -> f64
Get the latitude range of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.latitude_range(), 44.0);
fn longitude_range(&self) -> f64
Get the longitude range of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 99.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.longitude_range(), 54.0);
fn latitude_error(&self) -> f64
Get the latitude error from the center point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.latitude_error(), 22.0);
fn longitude_error(&self) -> f64
Get the longitude error from the center point of the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 99.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert_eq!(b.longitude_error(), 27.0);
fn contains(&self, point: &GeoLocation) -> bool
Test if a GeoLocation
is in the bounding box
Example
let b=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 99.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); assert!(b.contains(&geohashrust::GeoLocation::from_coordinates(33.0, 55.0))); assert!(!b.contains(&geohashrust::GeoLocation::from_coordinates(13.0, 55.0)));
fn merge_with(&mut self, other: &BoundingBox)
Merge another BoundingBox
into this one
Example
let mut box1=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 23.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 45.0, }, ); let box2=geohashrust::BoundingBox::from_geolocations( &geohashrust::GeoLocation{ latitude: 123.0, longitude: 89.0, }, &geohashrust::GeoLocation{ latitude: 67.0, longitude: 145.0, }, ); box1.merge_with(&box2); assert_eq!(box1.min_lat, 23.0); assert_eq!(box1.min_lon, 45.0); assert_eq!(box1.max_lat, 123.0); assert_eq!(box1.max_lon, 145.0);
Trait Implementations
impl Default for BoundingBox
[src]
fn default() -> BoundingBox
Returns the "default value" for a type. Read more
impl Clone for BoundingBox
[src]
fn clone(&self) -> BoundingBox
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for BoundingBox
[src]
impl PartialEq for BoundingBox
[src]
fn eq(&self, __arg_0: &BoundingBox) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &BoundingBox) -> bool
This method tests for !=
.