Struct Elements

Source
pub struct Elements {
Show 17 fields pub object_name: Option<String>, pub international_designator: Option<String>, pub norad_id: u64, pub classification: Classification, pub datetime: NaiveDateTime, pub mean_motion_dot: f64, pub mean_motion_ddot: f64, pub drag_term: f64, pub element_set_number: u64, pub inclination: f64, pub right_ascension: f64, pub eccentricity: f64, pub argument_of_perigee: f64, pub mean_anomaly: f64, pub mean_motion: f64, pub revolution_number: u64, pub ephemeris_type: u8,
}
Expand description

General perturbations orbital data parsed from a TLE or OMM

Elements can be retrieved from either a Two-Line Element Set (TLE) or an Orbit Mean-Elements Message (OMM). See https://celestrak.com/NORAD/documentation/gp-data-formats.php for more information on the difference between the two formats.

The fields’ documentation is adapted from https://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/SSOP_Help/tle_def.html.

See sgp4::Elements::from_tle to parse a TLE.

serde_json can be used to parse a JSON OMM object (into a sgp4::Elements) or a JSON list of OMM objects (into a Vec<sgp4::Elements>).

§Example

let elements: sgp4::Elements = serde_json::from_str(
    r#"{
        "OBJECT_NAME": "ISS (ZARYA)",
        "OBJECT_ID": "1998-067A",
        "EPOCH": "2020-07-12T01:19:07.402656",
        "MEAN_MOTION": 15.49560532,
        "ECCENTRICITY": 0.0001771,
        "INCLINATION": 51.6435,
        "RA_OF_ASC_NODE": 225.4004,
        "ARG_OF_PERICENTER": 44.9625,
        "MEAN_ANOMALY": 5.1087,
        "EPHEMERIS_TYPE": 0,
        "CLASSIFICATION_TYPE": "U",
        "NORAD_CAT_ID": 25544,
        "ELEMENT_SET_NO": 999,
        "REV_AT_EPOCH": 23587,
        "BSTAR": 0.0049645,
        "MEAN_MOTION_DOT": 0.00289036,
        "MEAN_MOTION_DDOT": 0
    }"#,
)?;

Fields§

§object_name: Option<String>
Available on crate feature alloc only.

The name associated with the satellite

§international_designator: Option<String>
Available on crate feature alloc only.

The satellite’s international designator

It consists of the launch year, the launch number of that year and a letter code representing the sequential identifier of a piece in a launch.

§norad_id: u64

The catalog number USSPACECOM has designated for this object

§classification: Classification

The elements’ classification

§datetime: NaiveDateTime

The UTC timestamp of the elements

§mean_motion_dot: f64

Time derivative of the mean motion

§mean_motion_ddot: f64

Second time derivative of the mean motion

§drag_term: f64

Radiation pressure coefficient in earth radii⁻¹

§element_set_number: u64

A running count of all 2 line element sets generated by USSPACECOM for this object

§inclination: f64

Angle between the equator and the orbit plane in deg

§right_ascension: f64

Angle between vernal equinox and the point where the orbit crosses the equatorial plane in deg

§eccentricity: f64

The shape of the orbit

§argument_of_perigee: f64

Angle between the ascending node and the orbit’s point of closest approach to the earth in deg

§mean_anomaly: f64

Angle of the satellite location measured from perigee in deg

§mean_motion: f64

Mean number of orbits per day in day⁻¹ (Kozai convention)

§revolution_number: u64

The orbit number at epoch

§ephemeris_type: u8

NORAD internal use, always 0 in distributed data

Implementations§

Source§

impl Elements

Source

pub fn from_tle( object_name: Option<String>, line1: &[u8], line2: &[u8], ) -> Result<Elements, Error>

Parses a Two-Line Element Set (TLE) with an optionnal title

§Arguments
  • object_name - The name of the satellite, usually given by a third line placed before the TLE
  • line1 - The first line of the TLE composed of 69 ASCII characters
  • line2 - The second line of the TLE composed of 69 ASCII characters
§Example
let elements = sgp4::Elements::from_tle(
    Some("ISS (ZARYA)".to_owned()),
    "1 25544U 98067A   08264.51782528 -.00002182  00000-0 -11606-4 0  2927".as_bytes(),
    "2 25544  51.6416 247.4627 0006703 130.5360 325.0288 15.72125391563537".as_bytes(),
)?;
Source

pub fn epoch(&self) -> f64

Returns the number of years since UTC 1 January 2000 12h00 (J2000)

This is the recommended method to calculate the epoch

Source

pub fn epoch_afspc_compatibility_mode(&self) -> f64

Returns the number of years since UTC 1 January 2000 12h00 (J2000) using the AFSPC expression

This function should be used if compatibility with the AFSPC implementation is needed

Source

pub fn datetime_to_minutes_since_epoch( &self, datetime: &NaiveDateTime, ) -> Result<MinutesSinceEpoch, DatetimeToMinutesSinceEpochError>

Returns the time difference in minutes between the given datetime and the elements’ epoch

This method does not take leap seconds into account

Source

pub fn minutes_since_epoch_to_datetime( &self, minutes_since_epoch: &MinutesSinceEpoch, ) -> Result<NaiveDateTime, MinutesSinceEpochToDatetimeError>

Builds a datetime from a number of minutes since epoch

This method does not take leap seconds into account

Trait Implementations§

Source§

impl Clone for Elements

Source§

fn clone(&self) -> Elements

Returns a copy 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 Elements

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Elements

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Elements

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,