Struct calendrical_calculations::astronomy::Location

source ·
pub struct Location {
    pub latitude: f64,
    pub longitude: f64,
    pub elevation: f64,
    pub zone: 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

§zone: f64

UTC timezone offset in fractional days (1 hr = 1.0 / 24.0 day)

Implementations§

source§

impl Location

source

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

Create a location; latitude is from -90 to 90, and longitude is from -180 to 180; attempting to create a location outside of these bounds will result in a LocationOutOfBoundsError.

source

pub const fn new_unchecked( latitude: f64, longitude: f64, elevation: f64, zone: f64, ) -> Location

Create a new Location without checking for bounds

source

pub fn longitude(&self) -> f64

Get the longitude of a Location

source

pub fn latitude(&self) -> f64

Get the latitude of a Location

source

pub fn elevation(&self) -> f64

Get the elevation of a Location

source

pub fn zone(&self) -> f64

Get the utc-offset of a Location

source

pub 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 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 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 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 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 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 copy of the value. Read more
1.0.0 · 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 Default for Location

source§

fn default() -> Location

Returns the “default value” for a type. Read more
source§

impl Copy 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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.