pub struct Object {
pub object_enum: Bodies,
pub object_name: String,
pub object_type: ObjectType,
pub longitude: f64,
pub latitude: f64,
pub speed_longitude: f64,
pub object_pos: ObjectPos,
pub split: SplitDegResult,
}Expand description
Object
Fields§
§object_enum: Bodies§object_name: String§object_type: ObjectType§longitude: f64§latitude: f64§speed_longitude: f64§object_pos: ObjectPos§split: SplitDegResultImplementations§
Source§impl Object
impl Object
Sourcepub fn new(
object_enum: Bodies,
object_name: &str,
object_type: ObjectType,
longitude: f64,
latitude: f64,
speed_longitude: f64,
) -> Object
pub fn new( object_enum: Bodies, object_name: &str, object_type: ObjectType, longitude: f64, latitude: f64, speed_longitude: f64, ) -> Object
Constructor
Examples found in repository?
examples/debug.rs (lines 77-84)
34fn main() {
35 println!("Swissephem C -> Rust");
36 // let swe02_path_final = "/src/swisseph/sweph";
37 // let swe02_path: String =
38 // env::var("CARGO_MANIFEST_DIR").unwrap() + swe02_path_final;
39 let swe02_path: &str =
40 "/Users/stephanebressani/Code/Rust/libswe-sys/src/swisseph/sweph";
41 handler_swe02::set_ephe_path(&swe02_path);
42 println!("Set the path of ephemeris to: {}", &swe02_path);
43 println!("Version swephem: {}", handler_swe02::version());
44 println!("Get path of library: {}", handler_swe02::get_library_path());
45
46 const PATH: &str = "examples/data.json";
47 let mut s = String::new();
48 let mut file_path = PathBuf::new();
49 file_path.push(env::current_dir().unwrap().as_path());
50 file_path.push(PATH);
51 File::open(file_path.as_path())
52 .unwrap()
53 .read_to_string(&mut s)
54 .unwrap();
55 let data: Data = serde_json::from_str(&s).unwrap();
56 println!("Data: {:?}", data);
57 let julday: f64 = handler_swe08::julday(
58 data.year,
59 data.month,
60 data.day,
61 data.hourf64,
62 Calandar::Gregorian,
63 );
64 println!("Get julday: {:?}", julday);
65
66 let mut object: Vec<Object> = Vec::new();
67 let mut calc: handler_swe03::CalcUtResult;
68 for bodies in Bodies::iter() {
69 if bodies.clone().object_type() == ObjectType::PlanetOrStar
70 || bodies.clone().object_type() == ObjectType::Fiction
71 {
72 calc = handler_swe03::calc_ut(
73 julday,
74 bodies.clone(),
75 OptionalFlag::Speed as i32,
76 );
77 object.push(Object::new(
78 bodies.clone(),
79 bodies.clone().as_static(),
80 bodies.clone().object_type(),
81 calc.longitude,
82 calc.latitude,
83 calc.speed_longitude,
84 ));
85 }
86 }
87
88 for o in object {
89 println!("{:?}", o);
90 }
91
92 let pheno_ut: handler_swe07::PhenoUtResult = handler_swe07::pheno_ut(
93 julday,
94 Bodies::Sun,
95 OptionalFlag::Speed as i32,
96 );
97 println!("PhenoUt: {:?}", pheno_ut);
98
99 // let hsys = HouseSystem::Placidus;
100 let name = handler_swe14::house_name('P');
101 println!("Hsys: {}", name);
102
103 let utc_time_zone: handler_swe08::UtcTimeZoneResult =
104 handler_swe08::utc_time_zone(
105 data.year, data.month, data.day, data.hour, data.min, data.sec, 2.0,
106 );
107 println!("utc_time_zone: {:?}", utc_time_zone);
108
109 let utc_to_jd: handler_swe08::UtcToJdResult = handler_swe08::utc_to_jd(
110 utc_time_zone.year[0],
111 utc_time_zone.month[0],
112 utc_time_zone.day[0],
113 utc_time_zone.hour[0],
114 utc_time_zone.min[0],
115 utc_time_zone.sec[0],
116 /*utc_time_zone.year[1],
117 utc_time_zone.month[1],
118 utc_time_zone.day[1],
119 utc_time_zone.hour[1],
120 utc_time_zone.min[1],
121 utc_time_zone.sec[1],*/
122 Calandar::Gregorian,
123 );
124 println!("utc_to_jd: {:?}", utc_to_jd);
125
126 // Whole signs
127 let result_w =
128 handler_swe14::houses(utc_to_jd.julian_day_ut, data.lat, data.lng, 'W');
129 //println!("House object: {:?}", result);
130 let mut house2: Vec<House> = Vec::new();
131 for (i, res) in result_w.clone().cusps.iter().enumerate() {
132 if i > 0 {
133 // No angle calculation when Nothing
134 let angle = Angle::Nothing;
135 house2.push(House::new(i as i32, res.clone(), angle));
136 if i + 1 > 12 {
137 break;
138 }
139 }
140 }
141
142 for h in house2 {
143 println!("{:?}", h);
144 }
145 println!("House (wohle signs): {:?}", result_w.clone());
146
147 // Wohle Signs
148 let result =
149 handler_swe14::houses(utc_to_jd.julian_day_ut, data.lat, data.lng, 'P');
150 //println!("House object: {:?}", result);
151 let mut house: Vec<House> = Vec::new();
152 for (i, res) in result.clone().cusps.iter().enumerate() {
153 if i > 0 {
154 let angle;
155 /*
156 if result.clone().ascmc[0] == res.clone() {
157 angle = Angle::Asc;
158 }
159 if result.clone().ascmc[1] == res.clone() {
160 angle = Angle::Fc;
161 }
162 if result.clone().ascmc[2] == res.clone() {
163 angle = Angle::Desc;
164 }
165 if result.clone().ascmc[3] == res.clone() {
166 angle = Angle::Mc;
167 }*/
168 // This is tested with Placidus only
169 // the line above ascmc[?] don't work for Desc and Mc
170 angle = match i {
171 1 => Angle::Asc,
172 4 => Angle::Fc,
173 7 => Angle::Desc,
174 10 => Angle::Mc,
175 _ => Angle::Nothing,
176 };
177 house.push(House::new(i as i32, res.clone(), angle));
178 if i + 1 > 12 {
179 break;
180 }
181 }
182 }
183
184 for h in house {
185 println!("{:?}", h);
186 }
187 println!("House (Placidus): {:?}", result.clone());
188
189 // Fortuna part
190 let calcfp = handler_swe03::calc_ut_fp(
191 julday,
192 data.lat,
193 data.lng,
194 'P',
195 OptionalFlag::Speed as i32,
196 );
197 println!("Fortuna Part: {}", calcfp.longitude);
198
199 println!("Exit and free memory swephem");
200 handler_swe02::close();
201}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more