Skip to main content

Location

Struct Location 

Source
pub struct Location {
    pub(crate) latitude: f64,
    pub(crate) longitude: f64,
    pub(crate) elevation: f64,
    pub(crate) utc_offset: f64,
}
Expand description

A Location on the Earth given as a latitude, longitude, elevation, and standard time zone. Latitude is given in degrees from -90 to 90, longitude in degrees from -180 to 180, elevation in meters, and zone as a UTC offset in fractional days (ex. UTC+1 would have zone = 1.0 / 24.0)

Fields§

§latitude: f64

latitude from -90 to 90

§longitude: f64

longitude from -180 to 180

§elevation: f64

elevation in meters

§utc_offset: f64

UTC timezone offset in fractional days (1 hr = 1.0 / 24.0 day), within the range (-12.0 / 24.0) to (14.0 / 24.0)

Implementations§

Source§

impl Location

Source

pub fn try_new( latitude: f64, longitude: f64, elevation: f64, utc_offset: f64, ) -> Result<Location, LocationOutOfBoundsError>

Create a location; latitude is from -90 to 90, longitude is from -180 to 180, and utc_offset is from (-12.0 / 24.0) to (14.0 / 24.0); attempting to create a location outside of these bounds will result in a LocationOutOfBoundsError.

Source

pub(crate) fn longitude(&self) -> f64

Get the longitude of a Location

Source

pub(crate) fn latitude(&self) -> f64

Get the latitude of a Location

Source

pub(crate) fn elevation(&self) -> f64

Get the elevation of a Location

Source

pub(crate) fn zone(&self) -> f64

Get the utc-offset of a Location

Source

pub(crate) fn zone_from_longitude(longitude: f64) -> f64

Convert a longitude into a mean time zone; this yields the difference in Moment given a longitude e.g. a longitude of 90 degrees is 0.25 (90 / 360) days ahead of a location with a longitude of 0 degrees.

Source

pub(crate) fn standard_from_local( standard_time: Moment, location: Location, ) -> Moment

Convert standard time to local mean time given a location and a time zone with given offset

Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3501-L3506

Source

pub(crate) fn universal_from_local( local_time: Moment, location: Location, ) -> Moment

Convert from local mean time to universal time given a location

Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3496-L3499

Source

pub(crate) fn local_from_universal( universal_time: Moment, location: Location, ) -> Moment

Convert from universal time to local time given a location

Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3491-L3494

Source

pub(crate) fn universal_from_standard( standard_moment: Moment, location: Location, ) -> Moment

Given a UTC-offset in hours and a Moment in standard time, return the Moment in universal time from the time zone with the given offset. The field utc_offset should be within the range of possible offsets given by the constand fields MIN_UTC_OFFSET and MAX_UTC_OFFSET.

Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3479-L3483

Source

pub(crate) fn standard_from_universal( standard_time: Moment, location: Location, ) -> Moment

Given a Moment in standard time and UTC-offset in hours, return the Moment in standard time from the time zone with the given offset. The field utc_offset should be within the range of possible offsets given by the constand fields MIN_UTC_OFFSET and MAX_UTC_OFFSET.

Based on functions from Calendrical Calculations by Reingold & Dershowitz. Reference lisp code: https://github.com/EdReingold/calendar-code2/blob/9afc1f3/calendar.l#L3473-L3477

Trait Implementations§

Source§

impl Clone for Location

Source§

fn clone(&self) -> Location

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Location

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Location

Source§

fn eq(&self, other: &Location) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Location

Source§

impl StructuralPartialEq for Location

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.