Struct geohashrust::GeoLocation [] [src]

pub struct GeoLocation {
    pub latitude: f64,
    pub longitude: f64,
}

A geographic location.

Fields

Latitude in degrees.

Longitude in degrees.

Methods

impl GeoLocation
[src]

Creates a new GeoLocation with latitude and longitude set to zero.

Example

let l = geohashrust::GeoLocation::new();
assert_eq!(l.latitude, 0.0);
assert_eq!(l.longitude, 0.0);

Creates a new GeoLocation with latitude and longitude.

Example

let l = geohashrust::GeoLocation::from_coordinates(48.1333, 11.5667);
assert_eq!(l.latitude, 48.1333);
assert_eq!(l.longitude, 11.5667);

Returns the distance between self and other in meters. The calculation is done using the Haversine formula.

Example

let new_york = geohashrust::GeoLocation::from_coordinates(40.7127, -74.0059);
let helsinki = geohashrust::GeoLocation::from_coordinates(60.1708, 24.9375);
assert_eq!(new_york.distance_to(&helsinki).round(), 6618.0);

Trait Implementations

impl Default for GeoLocation
[src]

Returns the "default value" for a type. Read more

impl Clone for GeoLocation
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for GeoLocation
[src]

impl PartialEq for GeoLocation
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Sub<GeoLocation> for GeoLocation
[src]

Returns the distance between self and other in meters. The calculation is done using the Haversine formula.

Example

let new_york = geohashrust::GeoLocation::from_coordinates(40.7127, -74.0059);
let helsinki = geohashrust::GeoLocation::from_coordinates(60.1708, 24.9375);
assert_eq!((new_york-helsinki).round(), 6618.0);

The resulting type after applying the - operator

The method for the - operator