1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#![feature(use_extern_macros)]
#![allow(non_snake_case)]
#[macro_use]
extern crate assert_approx_eq;
#[macro_use]
extern crate serde_derive;
extern crate astro;
extern crate vsop87;
extern crate chrono;
use chrono::prelude::*;
use chrono::{DateTime, NaiveDateTime};
pub use astro::angle;
pub mod ascii_art;
pub mod moon;
pub mod sun;
pub mod planet;
pub mod star;
#[macro_use]
pub mod util;
pub mod coords;
#[cfg(test)]
mod tests {
use planet;
use star;
use coords::*;
const JULIAN_DAY: f64 = 2458061.2743171295;
const LOCATION: Location = Location {
lat: 38.44043,
lon: -122.71405,
};
#[test]
fn get_celestial_position_star_test() {
let celestial = star::get_celestial_position(JULIAN_DAY, "Polaris").unwrap();
let tolerence = 2.0;
assert_approx_eq!(37.954522, celestial.get_eq_coords().ra, tolerence);
assert_approx_eq!(89.264108, celestial.get_eq_coords().dec, tolerence);
}
#[test]
fn get_celestial_position_planet_test() {
let celestial = planet::get_celestial_position(JULIAN_DAY, "Venus").unwrap();
let tolerence = 0.004f64;
let dec = -8.45970181351729;
let ra = 204.04900114888179;
let az = 172.90148843919002;
let alt = 42.86299764225456;
assert_approx_eq!(dec, celestial.get_eq_coords().dec, tolerence);
assert_approx_eq!(ra, celestial.get_eq_coords().ra, tolerence);
assert_approx_eq!(az, celestial.get_hz_coords(LOCATION).az, tolerence);
assert_approx_eq!(alt, celestial.get_hz_coords(LOCATION).alt, tolerence);
}
}