pub struct GeoLocation { /* private fields */ }Expand description
A struct that contains location information such as latitude and longitude required for astronomical calculations. The elevation field may be ignored by calculations that do not account for elevation.
Construct with GeoLocation::new, which validates the coordinates.
Implementations§
Source§impl GeoLocation
impl GeoLocation
Sourcepub fn new(
latitude: f64,
longitude: f64,
elevation: f64,
timezone: TimeZone,
) -> Result<Self, GeoLocationError>
pub fn new( latitude: f64, longitude: f64, elevation: f64, timezone: TimeZone, ) -> Result<Self, GeoLocationError>
Returns a validated GeoLocation.
latitude is in the World Geodetic System, or degrees North of the
Equator, and must be in [-90.0, 90.0]. longitude is in the World
Geodetic System, or degrees East of the IERS Reference Meridian, and
must be in [-180.0, 180.0]. elevation is in meters above sea level
and must be non-negative and finite.
§Errors
Returns a GeoLocationError describing the first invalid parameter.
Examples found in repository?
7fn main() {
8 let new_york = TimeZone::get("America/New_York").unwrap();
9 // first night of slichos
10 let date = civil::date(2025, 9, 13);
11 let yu = GeoLocation::new(40.8506041, -73.9297205, 0.0, new_york).unwrap();
12
13 // beginning of the night
14 let sunset = zmanim_calculator::shkia(date, &yu, false).unwrap();
15
16 // add a day to calculate sunrise the next day
17 let tomorrow = date.add(Span::new().days(1));
18 // end of the night
19 let sunrise = zmanim_calculator::hanetz(tomorrow, &yu, false).unwrap();
20
21 // each ashmura is 1/3 of the night
22 let ashmura = sunrise.duration_since(&sunset) / 3;
23 // first chiluf mishmaros is one ashmura into the night
24 let chiluf1 = sunset.add(ashmura).strftime("%Y-%m-%d %H:%M:%S %Z");
25 println!("{chiluf1}");
26}More examples
7fn main() {
8 let jerusalem = TimeZone::get("Asia/Jerusalem").unwrap();
9 let today = Zoned::now().date();
10
11 // your location here
12 let kosel = GeoLocation::new(31.777, 35.234, 700.0, jerusalem).unwrap();
13
14 let dawn = astronomical_calculator::sunrise_offset_by_degrees(
15 today,
16 &kosel,
17 astronomical_calculator::ASTRONOMICAL_ZENITH,
18 )
19 .unwrap();
20 let sunrise = astronomical_calculator::sunrise(today, &kosel).unwrap();
21 let noon = astronomical_calculator::solar_noon(today, &kosel).unwrap();
22
23 // where the sun is right now
24 let now = Zoned::now();
25 let azimuth = astronomical_calculator::solar_azimuth(&now, &kosel);
26 let elevation = astronomical_calculator::solar_elevation(&now, &kosel);
27
28 println!(
29 "
30dawn: {dawn}
31sunrise: {sunrise}
32noon: {noon}
33
34solar azimuth now: {azimuth:.2} deg
35solar elevation now: {elevation:.2} deg
36"
37 )
38}7fn main() {
8 let jerusalem = TimeZone::get("Asia/Jerusalem").unwrap();
9 let today = Zoned::now().date();
10
11 // your location here
12 let kosel = GeoLocation::new(31.777, 35.234, 700.0, jerusalem).unwrap();
13 let czc = ComplexZmanimCalendar::new(kosel, today, UseElevation::No);
14
15 // look up a single zman by its method name
16 let entry = find_zman("sof_zman_shema_gra").unwrap();
17 if let Some(ZmanValue::Time(time)) = (entry.compute)(&czc) {
18 println!("{}: {}\n", entry.name, time.strftime("%H:%M:%S %Z"));
19 }
20
21 // iterate over every zero-argument zman accessor
22 for entry in ALL_ZMANIM {
23 match (entry.compute)(&czc) {
24 Some(ZmanValue::Time(time)) => {
25 println!("{}: {}", entry.name, time.strftime("%H:%M:%S %Z"));
26 }
27 Some(ZmanValue::Duration(duration)) => println!("{}: {duration:#}", entry.name),
28 None => println!("{}: does not occur today", entry.name),
29 }
30 }
31}7fn main() {
8 let jerusalem = TimeZone::get("Asia/Jerusalem").unwrap();
9 let today = Zoned::now().date();
10
11 // your location here
12 let kosel = GeoLocation::new(31.777, 35.234, 700.0, jerusalem).unwrap();
13
14 let czc = ComplexZmanimCalendar::new(kosel, today, UseElevation::No);
15
16 let alos = czc.alos_baal_hatanya().unwrap();
17 let hanetz = czc.hanetz().unwrap();
18 let szks = czc.sof_zman_shema_baal_hatanya().unwrap();
19 let szt = czc.sof_zman_tefila_baal_hatanya().unwrap();
20 let chatzos = czc.chatzos_hayom().unwrap();
21 let mg = czc.mincha_gedola_baal_hatanya().unwrap();
22 let mk = czc.mincha_ketana_baal_hatanya().unwrap();
23 let plag = czc.plag_baal_hatanya().unwrap();
24 let shkia = czc.shkia().unwrap();
25 let tzeis = czc.tzeis_baal_hatanya().unwrap();
26 let shaah = czc.shaah_zmanis_baal_hatanya().unwrap();
27
28 println!(
29 "alos: {alos}
30hanetz: {hanetz}
31SZKS: {szks}
32SZT: {szt}
33chatzos: {chatzos}
34MG: {mg}
35MK: {mk}
36shkia: {shkia}
37plag: {plag}
38tzeis: {tzeis}
39shaah zmanis: {shaah}"
40 )
41}8fn main() {
9 let jerusalem = TimeZone::get("Asia/Jerusalem").unwrap();
10 let today = Zoned::now().date();
11
12 let kosel = GeoLocation::new(31.777, 35.234, 700.0, jerusalem).unwrap();
13
14 let alos_10_deg =
15 zmanim_calculator::alos(today, &kosel, false, &ZmanOffset::Degrees(10.0)).unwrap();
16 let tzeis_13_deg =
17 zmanim_calculator::tzeis(today, &kosel, false, &ZmanOffset::Degrees(13.0)).unwrap();
18 let hanetz = zmanim_calculator::hanetz(today, &kosel, true).unwrap();
19 let szks = zmanim_calculator::sof_zman_shema(&alos_10_deg, &tzeis_13_deg);
20 let szt = zmanim_calculator::sof_zman_tefila(&alos_10_deg, &tzeis_13_deg);
21 let chatzos = zmanim_calculator::chatzos_hayom(today, &kosel).unwrap();
22 let mg = zmanim_calculator::mincha_gedola(&alos_10_deg, &tzeis_13_deg);
23 let mk = zmanim_calculator::mincha_ketana(&alos_10_deg, &tzeis_13_deg);
24 let plag = zmanim_calculator::plag_hamincha(&alos_10_deg, &tzeis_13_deg);
25 let shkia = zmanim_calculator::shkia(today, &kosel, true).unwrap();
26 let shaah = zmanim_calculator::shaah_zmanis(&alos_10_deg, &tzeis_13_deg);
27
28 println!(
29 "alos: {alos_10_deg}
30hanetz: {hanetz}
31SZKS: {szks}
32SZT: {szt}
33chatzos: {chatzos}
34MG: {mg}
35MK: {mk}
36shkia: {shkia}
37plag: {plag}
38tzeis: {tzeis_13_deg}
39shaah zmanis: {shaah}"
40 )
41}6fn main() {
7 let new_york = TimeZone::get("America/New_York").unwrap();
8
9 let yeshiva = GeoLocation::new(40.8506041, -73.9297205, 0.0, new_york).unwrap();
10
11 println!(
12 "Date, Alos 19.8°, Alos 18°, Misheyakir 6.5°, Hanetz, SZKS, SZT, Chatzos, MG, MK, Plag, Shkia, Tzeis 6°"
13 );
14
15 let mut date = civil::date(2027, 1, 1);
16 let end = civil::date(2027, 12, 30);
17 let mut czc = ComplexZmanimCalendar::new(yeshiva, date, UseElevation::No);
18 while date <= end {
19 czc.set_date(date);
20
21 println!(
22 "{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}",
23 date,
24 czc.alos_19_8_degrees().unwrap().strftime("%H:%M:%S"),
25 czc.alos_18_degrees().unwrap().strftime("%H:%M:%S"),
26 czc.alos(&ZmanOffset::Degrees(6.5))
27 .unwrap()
28 .strftime("%H:%M:%S"),
29 czc.hanetz().unwrap().strftime("%H:%M:%S"),
30 czc.sof_zman_shema_gra().unwrap().strftime("%H:%M:%S"),
31 czc.sof_zman_tefila_gra().unwrap().strftime("%H:%M:%S"),
32 czc.chatzos_hayom().unwrap().strftime("%H:%M:%S"),
33 czc.mincha_gedola_gra().unwrap().strftime("%H:%M:%S"),
34 czc.mincha_ketana_gra().unwrap().strftime("%H:%M:%S"),
35 czc.plag_gra().unwrap().strftime("%H:%M:%S"),
36 czc.shkia().unwrap().strftime("%H:%M:%S"),
37 czc.tzeis_baal_hatanya().unwrap().strftime("%H:%M:%S"),
38 );
39
40 date = date.tomorrow().unwrap();
41 }
42}Sourcepub fn latitude(&self) -> f64
pub fn latitude(&self) -> f64
The latitude in the World Geodetic System, or degrees North of the Equator
Sourcepub fn longitude(&self) -> f64
pub fn longitude(&self) -> f64
The longitude in the World Geodetic System, or degrees East of the IERS Reference Meridian
Sourcepub fn local_mean_time_offset(&self) -> f64
pub fn local_mean_time_offset(&self) -> f64
Returns the location’s local mean time offset from UTC in hours. The
globe is split into 360°, with 15° per hour of the day. For a
location that is at a longitude evenly divisible by 15 (longitude % 15 == 0), at solar noon (with adjustment for the equation of time)
the sun should be directly overhead, so a user who is 1° west of
this will have noon at 4 minutes after standard time noon, and
conversely, a user who is 1° east of the 15° longitude will have
noon at 11:56 AM. Lakewood, N.J., whose longitude is -74.222, is 0.778
away from the closest multiple of 15 at -75°. This is multiplied by
4 to yield 3 minutes and 7 seconds earlier than standard time. The
offset returned does not account for the daylight saving time offset
since this struct is unaware of dates.
Trait Implementations§
Source§impl Clone for GeoLocation
impl Clone for GeoLocation
Source§fn clone(&self) -> GeoLocation
fn clone(&self) -> GeoLocation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more