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]

`fn new() -> GeoLocation`

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

`fn from_coordinates(latitude: f64, longitude: f64) -> GeoLocation`

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

`fn distance_to(&self, other: &GeoLocation) -> f64`

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]

`fn default() -> GeoLocation`

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

`impl Clone for GeoLocation`[src]

`fn clone(&self) -> GeoLocation`

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 PartialEq for GeoLocation`[src]

`fn eq(&self, __arg_0: &GeoLocation) -> bool`

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

`fn ne(&self, __arg_0: &GeoLocation) -> bool`

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

`type Output = f64`

The resulting type after applying the `-` operator

`fn sub(self, rhs: GeoLocation) -> f64`

The method for the `-` operator