### GET /version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the version string of the underlying Swiss Ephemeris library. ```APIDOC ## GET /version ### Description Returns the version of the Swiss Ephemeris library currently in use. ### Method GET ### Endpoint /version ### Response #### Success Response (200) - **version** (string) - The library version string #### Response Example { "version": "2.10.03" } ``` -------------------------------- ### GET /swe_version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_version.html Retrieves the current version string of the Swiss Ephemeris library. ```APIDOC ## GET /swe_version ### Description Returns the version string of the Swiss Ephemeris library. The function writes the version into the provided buffer and returns a pointer to it. ### Method GET ### Endpoint /swe_version ### Parameters #### Request Body - **s** (*mut c_char) - Required - A pointer to a character buffer where the version string will be stored. ### Request Example { "s": "buffer_pointer" } ### Response #### Success Response (200) - **version** (string) - The version string of the library (e.g., "2.10.03"). #### Response Example { "version": "2.10.03" } ``` -------------------------------- ### GET /swe_version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/all.html?search=std%3A%3Avec Retrieves the version string of the underlying Swiss Ephemeris library. ```APIDOC ## GET /swe_version ### Description Returns the version number of the Swiss Ephemeris library currently in use. ### Method GET ### Endpoint /swe_version ### Response #### Success Response (200) - **version** (String) - The version string (e.g., "2.10.03"). #### Response Example { "version": "2.10.03" } ``` -------------------------------- ### GET /swe_houses Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph?search= Calculates house cusps and ascendant/MC positions for a given time and location. ```APIDOC ## GET /swe_houses ### Description Computes the house cusps for a specific geographic location and time using a selected house system. ### Method GET ### Endpoint /swe_houses ### Parameters #### Query Parameters - **tjd_ut** (REAL8) - Required - Julian Day in UT - **geolat** (REAL8) - Required - Geographic latitude - **geolon** (REAL8) - Required - Geographic longitude - **hsys** (char) - Required - House system character identifier ### Request Example { "tjd_ut": 2451545.0, "geolat": 48.0, "geolon": 11.0, "hsys": "P" } ### Response #### Success Response (200) - **cusps** (REAL8[]) - Array of 13 house cusps - **ascmc** (REAL8[]) - Array containing Ascendant, MC, ARMC, Vertex, etc. #### Response Example { "cusps": [120.5, 150.2, ...], "ascmc": [120.5, 30.2, ...] } ``` -------------------------------- ### GET /safe/calc Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/all.html?search=std%3A%3Avec Calculates the position of a celestial body using the safe wrapper interface. ```APIDOC ## GET /safe/calc ### Description Calculates the astronomical position of a specified planet or body at a given Julian Day. ### Method GET ### Endpoint /safe/calc ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian Day for the calculation. - **planet** (Planet) - Required - The enum identifier for the celestial body. - **flags** (CalcFlags) - Required - Bitwise flags for calculation settings. ### Request Example { "jd": 2451545.0, "planet": "Sun", "flags": "SEFLG_SPEED" } ### Response #### Success Response (200) - **position** (Position) - The calculated longitude, latitude, and distance data. #### Response Example { "longitude": 280.46, "latitude": 0.0, "distance": 0.98 } ``` -------------------------------- ### GET /safe/calc Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/all.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates the position of a celestial body using the safe wrapper interface. ```APIDOC ## GET /safe/calc ### Description Calculates the astronomical position of a specified planet or body at a given Julian Day. ### Method GET ### Endpoint /safe/calc ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian Day for the calculation. - **planet** (Planet) - Required - The target celestial body. - **flags** (CalcFlags) - Required - Calculation flags for precision and coordinate systems. ### Request Example { "jd": 2451545.0, "planet": "Sun", "flags": "SEFLG_SPEED" } ### Response #### Success Response (200) - **position** (Position) - The calculated longitude, latitude, and distance. #### Response Example { "longitude": 280.46, "latitude": 0.0, "distance": 0.983 } ``` -------------------------------- ### GET /version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.version.html?search=std%3A%3Avec Retrieves the current version string of the Swiss Ephemeris library. ```APIDOC ## GET /version ### Description Returns the version of the Swiss Ephemeris library as a string. ### Method GET ### Endpoint swiss_eph::safe::version() ### Parameters None ### Request Example N/A (Function call) ### Response #### Success Response (200) - **version** (String) - The version string of the Swiss Ephemeris library. #### Response Example "0.2.1" ``` -------------------------------- ### GET /version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.version.html?search=u32+-%3E+bool Retrieves the current version string of the Swiss Ephemeris library. ```APIDOC ## GET /version ### Description Returns the version string of the Swiss Ephemeris library currently in use. ### Method GET ### Endpoint swiss_eph::safe::version() ### Parameters None ### Request Example N/A (Function call) ### Response #### Success Response (200) - **version** (String) - The version string of the Swiss Ephemeris library. #### Response Example "2.10.03" ``` -------------------------------- ### GET swe_version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_version.html?search=std%3A%3Avec Retrieves the current version string of the Swiss Ephemeris library. ```APIDOC ## GET swe_version ### Description Returns the version string of the Swiss Ephemeris library. This function is an FFI wrapper for the underlying C implementation. ### Method GET ### Endpoint swe_version ### Parameters #### Path Parameters - **s** (*mut c_char) - Required - A pointer to a character buffer where the version string will be stored. ### Request Example N/A (C FFI call) ### Response #### Success Response (200) - **return** (*mut c_char) - A pointer to the version string. #### Response Example "2.10.03" ``` -------------------------------- ### FFI Testing Patterns Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Examples of how to safely wrap and test Swiss Ephemeris FFI calls within Rust, demonstrating the use of unsafe blocks and buffer management. ```rust #[test] fn test_julday() { unsafe { let jd = swe_julday(2000, 1, 1, 12.0, SE_GREG_CAL); assert!((jd - 2451545.0).abs() < 0.0001); } } #[test] fn test_version() { unsafe { let mut buf = [0i8; 256]; swe_version(buf.as_mut_ptr()); assert!(buf[0] >= b'0' as i8 && buf[0] <= b'9' as i8); } } ``` -------------------------------- ### GET /phenomena Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.phenomena.html?search= Calculates planetary phenomena for a given Julian Day, planet, and calculation flags. ```APIDOC ## GET /phenomena ### Description Calculates the planetary phenomena based on the provided Julian Day, target planet, and specific calculation flags. ### Method GET ### Endpoint /phenomena ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian Day number for the calculation. - **planet** (Planet) - Required - The target planet identifier. - **flags** (CalcFlags) - Required - Bitmask flags for calculation settings. ### Request Example { "jd": 2451545.0, "planet": "Mars", "flags": "SEFLG_SPEED" } ### Response #### Success Response (200) - **phenomenon** (Phenomenon) - The calculated planetary phenomenon result. #### Response Example { "phenomenon": "rise" } ``` -------------------------------- ### GET /swe_calc_ut Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph?search= Calculates the position of a celestial body at a specific Universal Time (UT). ```APIDOC ## GET /swe_calc_ut ### Description Calculates the position of a planet or celestial object for a given Julian Day number in Universal Time. ### Method GET ### Endpoint /swe_calc_ut ### Parameters #### Query Parameters - **jd_ut** (REAL8) - Required - Julian Day number in Universal Time - **ipl** (int32) - Required - Planet identifier (e.g., SE_SUN) - **iflag** (int32) - Required - Calculation flags ### Request Example { "jd_ut": 2451545.0, "ipl": 0, "iflag": 2 } ### Response #### Success Response (200) - **xx** (REAL8[]) - Array containing longitude, latitude, distance, speed in longitude, speed in latitude, speed in distance #### Response Example { "xx": [280.46, 0.0, 1.0, 0.98, 0.0, 0.0] } ``` -------------------------------- ### GET /swe_pheno_ut Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_pheno_ut.html Calculates planetary phenomena for a given Universal Time using the Swiss Ephemeris library. ```APIDOC ## GET /swe_pheno_ut ### Description Calculates planetary phenomena (such as rising, setting, or meridian transit) for a specific celestial body at a given Universal Time. ### Method GET ### Endpoint /swe_pheno_ut ### Parameters #### Path Parameters - **tjd_ut** (c_double) - Required - The Julian day number in Universal Time. - **ipl** (int32) - Required - The identifier for the celestial body. - **iflag** (int32) - Required - Calculation flags for the ephemeris. #### Request Body - **attr** (*mut c_double) - Required - Pointer to an array where the resulting attributes will be stored. - **serr** (*mut c_char) - Required - Pointer to a buffer for error messages. ### Request Example { "tjd_ut": 2451545.0, "ipl": 0, "iflag": 1 } ### Response #### Success Response (200) - **return** (int32) - Returns 0 on success, or an error code on failure. #### Response Example { "status": 0, "message": "Success" } ``` -------------------------------- ### Providing Default Values with unwrap_or in Rust Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/type.Result.html?search= Shows how to use `unwrap_or` to get the `Ok` value or a provided default if the `Result` is an `Err`. The default value is eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### Astro Models Configuration Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html?search=std%3A%3Avec Functions to set and get astronomical models used by the library. ```APIDOC ## swe_set_astro_models / swe_get_astro_models ### Description `swe_set_astro_models` allows setting the astronomical models to be used. `swe_get_astro_models` retrieves the currently set models and their details. ### Method `pub fn` (Rust function signature, implies internal use or FFI binding) ### Endpoint N/A (This is a library function, not a web API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Example usage for setting models let samod: *mut c_char = b"SE_MOD_ALL\0".as_ptr() as *mut c_char; // Example: Use all models let iflag: i32 = 0; unsafe { swe_set_astro_models(samod, iflag); } // Example usage for getting models let mut samod_buf = [0i8; 256]; let mut sdet_buf = [0i8; 256]; let iflag_get: i32 = 0; unsafe { swe_get_astro_models(samod_buf.as_mut_ptr(), sdet_buf.as_mut_ptr(), iflag_get); // Process the C-strings obtained in samod_buf and sdet_buf } ``` ### Response #### Success Response - **`swe_set_astro_models`**: No direct return value, modifies internal state. - **`swe_get_astro_models`**: - **samod** (*mut c_char) - Buffer to receive the names of the set models. - **sdet** (*mut c_char) - Buffer to receive details about the models. - **Return Value** (i32) - An integer indicating success or failure. #### Response Example (No direct JSON response as this is a C-style function call. Results are returned via output parameters or by modifying internal state.) ``` -------------------------------- ### Test Version Retrieval Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html?search= Unit test for the `swe_version` function, ensuring that the retrieved version string starts with a digit, indicating a valid version format. ```rust #[cfg(test)] mod tests { use super::* #[test] fn test_version() { unsafe { let mut buf = [0i8; 256]; swe_version(buf.as_mut_ptr()); // Version should start with a digit assert!(buf[0] >= b'0' as i8 && buf[0] <= b'9' as i8); } } } ``` -------------------------------- ### Get Swiss Ephemeris Version Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html?search= Retrieves the version string of the Swiss Ephemeris library. The function populates a provided buffer with the version information. The version string typically starts with a digit. ```rust pub fn swe_version(swe_version: *mut c_char); ``` -------------------------------- ### Initialize and Configure RiseTransFlags in Rust Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/struct.RiseTransFlags.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to instantiate the RiseTransFlags builder and apply various configuration methods to set specific flags. The raw method is used to retrieve the final integer representation of the configured flags. ```Rust use swiss_eph::safe::RiseTransFlags; let flags = RiseTransFlags::new() .with_rise() .with_set() .with_disc_center(); let raw_value = flags.raw(); ``` -------------------------------- ### Getting Swiss Ephemeris Version (Rust) Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/safe.rs.html Retrieves the version string of the installed Swiss Ephemeris library. This is useful for debugging, compatibility checks, and ensuring that the correct version of the library is being used. ```rust /// Get Swiss Ephemeris version #[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen)] pub fn version() -> String { let mut buf = [0i8; 256]; unsafe { swe_version(buf.as_mut_ptr()); CStr::from_ptr(buf.as_ptr()).to_string_lossy().into_owned() } } ``` -------------------------------- ### GET /calc Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/safe.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates the position of a celestial body for a given Julian Day and set of calculation flags. ```APIDOC ## GET /calc ### Description Calculates the astronomical position and speed of a specified planet at a given Julian Day (TT). ### Method GET ### Endpoint /calc ### Parameters #### Query Parameters - **jd** (f64) - Required - Julian Day in Terrestrial Time. - **planet** (int) - Required - Integer identifier for the planet. - **flags** (int) - Required - Bitwise flags for calculation options. ### Response #### Success Response (200) - **longitude** (f64) - Ecliptic longitude. - **latitude** (f64) - Ecliptic latitude. - **distance** (f64) - Distance in AU. - **longitude_speed** (f64) - Speed in longitude. - **latitude_speed** (f64) - Speed in latitude. - **distance_speed** (f64) - Speed in distance. #### Response Example { "longitude": 120.5, "latitude": 0.2, "distance": 1.01, "longitude_speed": 0.98, "latitude_speed": 0.0, "distance_speed": 0.0 } ``` -------------------------------- ### Handling File Metadata with Result in Rust Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/type.Result.html?search= Shows how to use `Result` and `and_then` to safely access file metadata, specifically the modification time. It includes examples for a valid path and an invalid path, demonstrating error handling with `ErrorKind::NotFound`. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Get Current File Data Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html?search=std%3A%3Avec Retrieves data about the current ephemeris file being used. It takes a file number and mutable pointers for the start and end Julian days, and a denumerator. Returns a constant character pointer to the file name. ```rust pub fn swe_get_current_file_data(ifno: c_int, tfstart: *mut c_double, tfend: *mut c_double, denum: *mut c_int) -> *const c_char; ``` -------------------------------- ### Get Current File Data Function Signature (C) Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_get_current_file_data.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This C function signature is part of the swiss-eph library. It retrieves data related to the current file, likely for astronomical calculations. It takes file information, start and end time pointers, and a denominator pointer as input, returning a character pointer to the data. ```rust pub unsafe extern "C" fn swe_get_current_file_data( ifno: c_int, tfstart: *mut c_double, tfend: *mut c_double, denum: *mut c_int, ) -> *const c_char ``` -------------------------------- ### Constant SE_SIDM_GALEQU_TRUE Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/constant.SE_SIDM_GALEQU_TRUE.html?search=std%3A%3Avec Documentation for the constant SE_SIDM_GALEQU_TRUE. ```APIDOC ## Constant SE_SIDM_GALEQU_TRUE ### Description Represents a constant value used within the swiss-eph library. ### Method N/A (Constant Declaration) ### Endpoint N/A (Constant Declaration) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (N/A) - **SE_SIDM_GALEQU_TRUE** (c_int) - The integer value of the constant, which is 32. #### Response Example ```rust pub const SE_SIDM_GALEQU_TRUE: c_int = 32; ``` ``` -------------------------------- ### GET /safe/houses Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/all.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates house cusps for a specific geographic location and time. ```APIDOC ## GET /safe/houses ### Description Computes the house cusps based on the provided Julian Day, geographic latitude, longitude, and house system. ### Method GET ### Endpoint /safe/houses ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian Day. - **lat** (f64) - Required - Geographic latitude. - **lon** (f64) - Required - Geographic longitude. - **hsys** (HouseSystem) - Required - The house system (e.g., Placidus, Koch). ### Request Example { "jd": 2451545.0, "lat": 48.85, "lon": 2.35, "hsys": "Placidus" } ### Response #### Success Response (200) - **cusps** (Vec) - Array of house cusp degrees. #### Response Example { "cusps": [120.5, 150.2, 180.0, 210.5, 240.2, 270.0] } ``` -------------------------------- ### String Formatting for Time and Coordinates (Rust) Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html Formats centisecond values into human-readable strings for time, longitude, latitude, and degrees. These functions are useful for displaying astronomical data. ```rust pub fn swe_cs2timestr(t: CSEC, sep: c_int, suppress_zero: AS_BOOL, a: *mut c_char) -> *mut c_char; pub fn swe_cs2lonlatstr(t: CSEC, pchar: c_char, mchar: c_char, s: *mut c_char) -> *mut c_char; pub fn swe_cs2degstr(t: CSEC, a: *mut c_char) -> *mut c_char; ``` -------------------------------- ### Get Planet Name Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.get_planet_name.html?search= Retrieves the name of a given planet. ```APIDOC ## get_planet_name ### Description Get planet name. ### Method GET ### Endpoint /planets/{planet_id}/name ### Parameters #### Path Parameters - **planet** (Planet) - Required - The planet for which to retrieve the name. ### Response #### Success Response (200) - **name** (String) - The name of the planet. #### Response Example ```json { "name": "Earth" } ``` ``` -------------------------------- ### GET swe_get_planet_name Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_get_planet_name.html?search=std%3A%3Avec Retrieves the name of a planet based on its integer identifier. ```APIDOC ## GET swe_get_planet_name ### Description Retrieves the name of a planet or celestial body based on the provided integer identifier (ipl) and stores it in the provided character buffer. ### Method GET ### Endpoint swe_get_planet_name(ipl: c_int, spname: *mut c_char) ### Parameters #### Path Parameters - **ipl** (c_int) - Required - The integer identifier for the planet. - **spname** (*mut c_char) - Required - A pointer to a character buffer where the planet name will be written. ### Request Example { "ipl": 0, "spname": "buffer_pointer" } ### Response #### Success Response (200) - **return** (*mut c_char) - A pointer to the character buffer containing the planet name. #### Response Example { "name": "Sun" } ``` -------------------------------- ### Configure Calculation Flags with CalcFlags Builder in Rust Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/struct.CalcFlags.html Demonstrates how to instantiate and configure the CalcFlags builder to specify astronomical calculation parameters. The builder pattern allows chaining methods to enable specific features like speed calculation, heliocentric positioning, or specific ephemeris sources. ```rust use swiss_eph::safe::CalcFlags; let flags = CalcFlags::new() .with_speed() .with_heliocentric() .with_no_nutation(); let raw_value = flags.raw(); ``` -------------------------------- ### Orbital Elements and Positions Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html Functions to retrieve orbital elements and calculate positions of celestial bodies. ```APIDOC ## GET /swe_nod_aps ### Description Calculates the apparent geocentric ecliptical coordinates of a planet or lunar node. ### Method GET ### Endpoint /swe_nod_aps ### Parameters #### Query Parameters - **tjd_et** (double) - Required - Julian day for ephemeris time. - **ipl** (int32) - Required - Planet or lunar node ID. - **iflag** (int32) - Required - Calculation flags. - **method** (int32) - Required - Calculation method. ### Request Example ``` GET /swe_nod_aps?tjd_et=2451545.0&ipl=1&iflag=1&method=0 ``` ### Response #### Success Response (200) - **xnasc** (double) - Right ascension. - **xndsc** (double) - Declination. - **xperi** (double) - Distance. - **xaphe** (double) - Argument of latitude. #### Response Example ```json { "xnasc": 10.123, "xndsc": 20.456, "xperi": 1.234, "xaphe": 50.789 } ``` ## GET /swe_nod_aps_ut ### Description Calculates the apparent geocentric ecliptical coordinates of a planet or lunar node using UT. ### Method GET ### Endpoint /swe_nod_aps_ut ### Parameters #### Query Parameters - **tjd_ut** (double) - Required - Julian day for universal time. - **ipl** (int32) - Required - Planet or lunar node ID. - **iflag** (int32) - Required - Calculation flags. - **method** (int32) - Required - Calculation method. ### Request Example ``` GET /swe_nod_aps_ut?tjd_ut=2451545.0&ipl=1&iflag=1&method=0 ``` ### Response #### Success Response (200) - **xnasc** (double) - Right ascension. - **xndsc** (double) - Declination. - **xperi** (double) - Distance. - **xaphe** (double) - Argument of latitude. #### Response Example ```json { "xnasc": 10.123, "xndsc": 20.456, "xperi": 1.234, "xaphe": 50.789 } ``` ## GET /swe_get_orbital_elements ### Description Retrieves the orbital elements of a planet or lunar node. ### Method GET ### Endpoint /swe_get_orbital_elements ### Parameters #### Query Parameters - **tjd_et** (double) - Required - Julian day for ephemeris time. - **ipl** (int32) - Required - Planet or lunar node ID. - **iflag** (int32) - Required - Calculation flags. ### Request Example ``` GET /swe_get_orbital_elements?tjd_et=2451545.0&ipl=1&iflag=1 ``` ### Response #### Success Response (200) - **dret** (array of doubles) - Array containing orbital elements. #### Response Example ```json { "dret": [ 10.123, 20.456, 1.234, 50.789, 60.111, 70.222 ] } ``` ## GET /swe_orbit_max_min_true_distance ### Description Calculates the maximum, minimum, and true distances for a planet or lunar node. ### Method GET ### Endpoint /swe_orbit_max_min_true_distance ### Parameters #### Query Parameters - **tjd_et** (double) - Required - Julian day for ephemeris time. - **ipl** (int32) - Required - Planet or lunar node ID. - **iflag** (int32) - Required - Calculation flags. ### Request Example ``` GET /swe_orbit_max_min_true_distance?tjd_et=2451545.0&ipl=1&iflag=1 ``` ### Response #### Success Response (200) - **dmax** (double) - Maximum distance. - **dmin** (double) - Minimum distance. - **dtrue** (double) - True distance. #### Response Example ```json { "dmax": 1.5, "dmin": 0.8, "dtrue": 1.1 } ``` ``` -------------------------------- ### GET swe_get_ayanamsa_ex Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_get_ayanamsa_ex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates the ayanamsa for a given Julian day and flags. ```APIDOC ## GET swe_get_ayanamsa_ex ### Description Calculates the ayanamsa value for a specific Ephemeris Time (ET) Julian day based on provided flags. ### Method GET ### Endpoint swe_get_ayanamsa_ex ### Parameters #### Path Parameters - **tjd_et** (c_double) - Required - Julian day number in Ephemeris Time - **iflag** (int32) - Required - Calculation flags - **daya** (*mut c_double) - Required - Pointer to store the resulting ayanamsa value - **serr** (*mut c_char) - Required - Pointer to a buffer for error messages ### Request Example { "tjd_et": 2451545.0, "iflag": 1 } ### Response #### Success Response (200) - **return** (int32) - Returns 0 on success, or an error code on failure. #### Response Example { "status": 0, "ayanamsa": 23.85 } ``` -------------------------------- ### Convert Result to Option with Ok value (Rust) Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/type.Result.html?search= Shows how to use the `ok` method to convert a `Result` into an `Option`. This consumes the Result and returns `Some(T)` if it was `Ok`, or `None` if it was `Err`. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` -------------------------------- ### Time and Day Conversion (Rust) Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html Converts decimal days to an integer and determines the day of the week for a given Julian Day. ```rust pub fn swe_d2l(x: c_double) -> int32; pub fn swe_day_of_week(jd: c_double) -> c_int; ``` -------------------------------- ### Rust Blanket Implementation of CloneToUninit for T Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/enum.Planet.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Presents a nightly-only experimental blanket implementation of CloneToUninit for types T that implement Clone. This unsafe function allows copying data to uninitialized memory. ```Rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) } ``` -------------------------------- ### Get Ayanamsa Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.get_ayanamsa.html Retrieves the ayanamsa (sidereal offset) for a given Julian day. ```APIDOC ## GET /ayanamsa ### Description Retrieves the ayanamsa (sidereal offset) for a given Julian day. ### Method GET ### Endpoint /ayanamsa ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian day for which to calculate the ayanamsa. ### Request Example ``` GET /ayanamsa?jd=2451545.0 ``` ### Response #### Success Response (200) - **ayanamsa** (f64) - The calculated ayanamsa value. #### Response Example ```json { "ayanamsa": 23.820000000000004 } ``` ``` -------------------------------- ### GET /swe_house_pos Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_house_pos.html?search= Calculates the house position based on the provided astronomical parameters. ```APIDOC ## GET /swe_house_pos ### Description Calculates the house position for a given set of astronomical coordinates and system parameters. ### Method GET ### Endpoint /swe_house_pos ### Parameters #### Query Parameters - **armc** (double) - Required - The ARMC (Right Ascension of the Midheaven). - **geolat** (double) - Required - The geographic latitude. - **eps** (double) - Required - The obliquity of the ecliptic. - **hsys** (int) - Required - The house system identifier. - **xpin** (pointer) - Required - Pointer to input double array. - **serr** (pointer) - Optional - Pointer to error string buffer. ### Request Example { "armc": 120.5, "geolat": 45.0, "eps": 23.4, "hsys": 80 } ### Response #### Success Response (200) - **result** (double) - The calculated house position. #### Response Example { "result": 15.23 } ``` -------------------------------- ### Get Planet Name Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_get_planet_name.html?search= Retrieves the name of a planet given its integer identifier. ```APIDOC ## swe_get_planet_name ### Description Retrieves the name of a planet based on its integer identifier. ### Method This is a function call within the swiss-eph library, not a direct HTTP API endpoint. ### Endpoint N/A (Library Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```c // Example usage (conceptual, requires C FFI bindings) int planet_id = 1; // Example ID for Sun char planet_name[256]; char* result = swe_get_planet_name(planet_id, planet_name); if (result != NULL) { printf("Planet name: %s\n", planet_name); } ``` ### Response #### Success Response (Return Value) - ***mut c_char** - A pointer to a C-style string containing the planet's name. Returns NULL on error. #### Response Example ``` // Conceptual response: A pointer to a string like "Sun" ``` ``` -------------------------------- ### Get Ayanamsa Name Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_get_ayanamsa_name.html?search=std%3A%3Avec Retrieves the name of the Ayanamsa based on the provided mode. ```APIDOC ## swe_get_ayanamsa_name ### Description Retrieves the name of the Ayanamsa based on the provided mode. ### Method This appears to be a function call within the swiss_eph library, not a direct HTTP API endpoint. ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example This is a function call, not a request body. ```rust let ayanamsa_name_ptr = swiss_eph::swe_get_ayanamsa_name(mode); ``` ### Response #### Success Response - ***const c_char** - A pointer to a C-style string containing the Ayanamsa name. #### Response Example ```rust // Assuming ayanamsa_name_ptr is a valid pointer returned from swe_get_ayanamsa_name let ayanamsa_name_str = unsafe {{ std::ffi::CStr::from_ptr(ayanamsa_name_ptr).to_string_lossy() }}; println!("Ayanamsa Name: {{}}", ayanamsa_name_str); ``` ``` -------------------------------- ### GET /nodes_apsides Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.nodes_apsides.html?search= Calculates the nodes and apsides for a given planet at a specific Julian Day. ```APIDOC ## GET /nodes_apsides ### Description Calculates the nodes and apsides for a specified planet using the provided Julian Day, calculation flags, and method. ### Method GET ### Endpoint /nodes_apsides ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian Day for the calculation. - **planet** (Planet) - Required - The target planet for the calculation. - **flags** (CalcFlags) - Required - Configuration flags for the calculation. - **method** (i32) - Required - The specific calculation method to apply. ### Request Example { "jd": 2451545.0, "planet": "Mars", "flags": 0, "method": 1 } ### Response #### Success Response (200) - **NodeApsides** (Object) - The calculated nodes and apsides data. #### Response Example { "node": 123.45, "apsis": 67.89 } ``` -------------------------------- ### Handling File Metadata Operations with Result in Rust Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/type.Result.html?search=u32+-%3E+bool Illustrates using Result for file system operations, specifically retrieving metadata. It shows how to handle potential errors like 'NotFound' when accessing file paths. The example uses `Path::new` and `metadata()` which return a Result. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### GET /get_planet_name Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.get_planet_name.html?search=std%3A%3Avec Retrieves the human-readable name of a planet based on the provided Planet identifier. ```APIDOC ## GET get_planet_name ### Description Returns the string representation of a planet name given a Planet enum variant. ### Method GET ### Endpoint get_planet_name ### Parameters #### Request Body - **planet** (Planet) - Required - The planet identifier to look up. ### Request Example { "planet": "Sun" } ### Response #### Success Response (200) - **name** (String) - The name of the planet. #### Response Example { "name": "Sun" } ``` -------------------------------- ### Calculate Node Ascending/Descending Positions (Rust) Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html Calculates the ascending and descending node positions for a celestial body. It takes Julian Day, planet ID, flags, and method as input, returning various positional data and an error code. ```rust pub fn swe_nod_aps(tjd_et: c_double, ipl: int32, iflag: int32, method: int32, xnasc: *mut c_double, xndsc: *mut c_double, xperi: *mut c_double, xaphe: *mut c_double, serr: *mut c_char) -> int32; pub fn swe_nod_aps_ut(tjd_ut: c_double, ipl: int32, iflag: int32, method: int32, xnasc: *mut c_double, xndsc: *mut c_double, xperi: *mut c_double, xaphe: *mut c_double, serr: *mut c_char) -> int32; ``` -------------------------------- ### Get Ayanamsa Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/fn.get_ayanamsa.html?search=u32+-%3E+bool Retrieves the ayanamsa (sidereal offset) based on the Julian day. ```APIDOC ## GET /ayanamsa ### Description Retrieves the ayanamsa (sidereal offset) for a given Julian day. ### Method GET ### Endpoint /ayanamsa ### Parameters #### Query Parameters - **jd** (f64) - Required - The Julian day for which to calculate the ayanamsa. ### Request Example ``` GET /ayanamsa?jd=2451545.0 ``` ### Response #### Success Response (200) - **ayanamsa** (f64) - The calculated ayanamsa value. #### Response Example ```json { "ayanamsa": 23.8348 } ``` ``` -------------------------------- ### POST /calc Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates the planetary position for a given Julian Day and planet identifier. ```APIDOC ## POST /calc ### Description Calculates the planetary position for a specific celestial body at a given Julian Day. ### Method POST ### Endpoint /calc ### Parameters #### Request Body - **jd** (f64) - Required - Julian Day number - **planet** (Planet) - Required - The planet identifier (e.g., SE_SUN, SE_MOON) - **flags** (CalcFlags) - Required - Calculation flags for precision and coordinate system ### Request Example { "jd": 2451545.0, "planet": "SE_SUN", "flags": "SEFLG_SPEED" } ### Response #### Success Response (200) - **position** (Position) - The calculated planetary coordinates and speed #### Response Example { "longitude": 280.46, "latitude": 0.0, "distance": 0.98, "speed_lon": 1.0 } ``` -------------------------------- ### Get Swiss Eph Version Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_version.html?search=u32+-%3E+bool Retrieves the version string of the Swiss Eph library. ```APIDOC ## GET /swe_version ### Description Retrieves the version string of the Swiss Eph library. ### Method GET ### Endpoint /swe_version ### Parameters #### Query Parameters - **s** (string) - Required - A character pointer to store the version string. ### Request Example ``` GET /swe_version?s=some_buffer ``` ### Response #### Success Response (200) - **version** (string) - The version string of the Swiss Eph library. #### Response Example ```json { "version": "0.2.1" } ``` ``` -------------------------------- ### Tidal Acceleration Functions Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html Functions for managing tidal acceleration settings. ```APIDOC ## GET /swe_get_tid_acc ### Description Retrieves the current tidal acceleration value. ### Method GET ### Endpoint /swe_get_tid_acc ### Response #### Success Response (200) - **tidal_acceleration** (double) - The current tidal acceleration value. #### Response Example ```json { "tidal_acceleration": 0.0 } ``` ## POST /swe_set_tid_acc ### Description Sets the tidal acceleration value. ### Method POST ### Endpoint /swe_set_tid_acc ### Parameters #### Request Body - **t_acc** (double) - Required - The tidal acceleration value to set. ### Request Example ```json { "t_acc": 0.0 } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Tidal acceleration set successfully." } ``` ## POST /swe_set_delta_t_userdef ### Description Sets a user-defined Delta T value. ### Method POST ### Endpoint /swe_set_delta_t_userdef ### Parameters #### Request Body - **dt** (double) - Required - The user-defined Delta T value. ### Request Example ```json { "dt": 69.1835 } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "User-defined Delta T set successfully." } ``` ``` -------------------------------- ### POST /calc Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/safe/index.html?search= Calculates the planetary position for a given Julian Day and planet identifier. ```APIDOC ## POST /calc ### Description Calculates the planetary position based on the provided Julian Day and planet identifier. ### Method POST ### Endpoint /calc ### Parameters #### Request Body - **jd** (f64) - Required - Julian Day number - **planet** (Planet) - Required - Planet identifier enum - **flags** (CalcFlags) - Required - Calculation flags builder ### Request Example { "jd": 2451545.0, "planet": "Sun", "flags": "SEFLG_SPEED" } ### Response #### Success Response (200) - **position** (Position) - The calculated planetary position object #### Response Example { "longitude": 280.46, "latitude": 0.0, "distance": 1.0 } ``` -------------------------------- ### GET swe_sidtime Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_sidtime.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates the sidereal time for a given Universal Time Julian Day. ```APIDOC ## GET swe_sidtime ### Description Calculates the sidereal time based on the provided Universal Time Julian Day (tjd_ut). ### Method GET ### Endpoint swe_sidtime ### Parameters #### Query Parameters - **tjd_ut** (c_double) - Required - The Julian Day number in Universal Time. ### Request Example { "tjd_ut": 2451545.0 } ### Response #### Success Response (200) - **sidereal_time** (c_double) - The calculated sidereal time. #### Response Example { "sidereal_time": 6.6345 } ``` -------------------------------- ### GET /swe_get_ayanamsa_name Source: https://docs.rs/swiss-eph/0.2.1/swiss_eph/fn.swe_get_ayanamsa_name.html Retrieves the name of a specific ayanamsa mode used in astronomical calculations. ```APIDOC ## GET /swe_get_ayanamsa_name ### Description Returns the name of the ayanamsa corresponding to the provided identifier mode. ### Method GET ### Endpoint /swe_get_ayanamsa_name ### Parameters #### Query Parameters - **isidmode** (int32) - Required - The identifier for the ayanamsa mode. ### Request Example GET /swe_get_ayanamsa_name?isidmode=0 ### Response #### Success Response (200) - **name** (string) - The name of the ayanamsa. #### Response Example { "name": "Fagan-Bradley" } ``` -------------------------------- ### FFI Bindings for Swiss Ephemeris Source: https://docs.rs/swiss-eph/0.2.1/src/swiss_eph/lib.rs.html Foreign Function Interface declarations for the 'swisseph' library, enabling Rust to call core astronomical functions like planet calculation, fixed star positioning, and time conversion. ```rust #[link(name = "swisseph")] unsafe extern "C" { pub fn swe_calc(tjd: c_double, ipl: c_int, iflag: int32, xx: *mut c_double, serr: *mut c_char) -> int32; pub fn swe_julday(year: c_int, month: c_int, day: c_int, hour: c_double, gregflag: c_int) -> c_double; pub fn swe_set_ephe_path(path: *const c_char); } ```