Skip to content

Commit

Permalink
refactor(satellite): rearrange code for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jan 13, 2025
1 parent b311718 commit 3ae37fb
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/satellite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,6 @@ pub enum Satellite {
}

impl Satellite {
/// Returns the international designator.
fn cospar_id(&self) -> Option<&str> {
match self {
Self::Iss => Some("1998-067A"),
Self::Css => Some("2021-035A"),
Self::Dfh1 => Some("1970-034A"),
_ => None,
}
}

/// Returns CelesTrak group name.
fn group(&self) -> Option<&str> {
match self {
Self::Weather => Some("weather"),
Self::Noaa => Some("noaa"),
Self::Goes => Some("goes"),
Self::EarthResources => Some("resource"),
Self::SearchRescue => Some("sarsat"),
Self::DisasterMonitoring => Some("dmc"),
Self::Gps => Some("gps-ops"),
Self::Glonass => Some("glo-ops"),
Self::Galileo => Some("galileo"),
Self::Beidou => Some("beidou"),
Self::SpaceEarthScience => Some("science"),
Self::Geodetic => Some("geodetic"),
Self::Engineering => Some("engineering"),
Self::Education => Some("education"),
Self::Military => Some("military"),
Self::RadarCalibration => Some("radar"),
Self::CubeSats => Some("cubesat"),
_ => None,
}
}

/// Returns SGP4 elements.
///
/// If cache is older than 2 hours, fetches elements from celestrak.org.
Expand Down Expand Up @@ -150,4 +116,38 @@ impl Satellite {
.expect("failed to parse JSON from celestrak.org"),
)
}

/// Returns the international designator.
fn cospar_id(&self) -> Option<&str> {
match self {
Self::Iss => Some("1998-067A"),
Self::Css => Some("2021-035A"),
Self::Dfh1 => Some("1970-034A"),
_ => None,
}
}

/// Returns CelesTrak group name.
fn group(&self) -> Option<&str> {
match self {
Self::Weather => Some("weather"),
Self::Noaa => Some("noaa"),
Self::Goes => Some("goes"),
Self::EarthResources => Some("resource"),
Self::SearchRescue => Some("sarsat"),
Self::DisasterMonitoring => Some("dmc"),
Self::Gps => Some("gps-ops"),
Self::Glonass => Some("glo-ops"),
Self::Galileo => Some("galileo"),
Self::Beidou => Some("beidou"),
Self::SpaceEarthScience => Some("science"),
Self::Geodetic => Some("geodetic"),
Self::Engineering => Some("engineering"),
Self::Education => Some("education"),
Self::Military => Some("military"),
Self::RadarCalibration => Some("radar"),
Self::CubeSats => Some("cubesat"),
_ => None,
}
}
}

0 comments on commit 3ae37fb

Please sign in to comment.