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