House

Struct House 

Source
pub struct House {
    pub object_id: i32,
    pub longitude: f64,
    pub split: SplitDegResult,
    pub angle: Angle,
}
Expand description

House

Fields§

§object_id: i32§longitude: f64§split: SplitDegResult§angle: Angle

Implementations§

Source§

impl House

Source

pub fn new(object_id: i32, longitude: f64, angle: Angle) -> House

Constructor

Examples found in repository?
examples/debug.rs (line 135)
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§

Source§

impl Clone for House

Source§

fn clone(&self) -> House

Returns a duplicate 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 House

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for House

§

impl RefUnwindSafe for House

§

impl Send for House

§

impl Sync for House

§

impl Unpin for House

§

impl UnwindSafe for House

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.