#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AirspaceType {
RemoteCommunicationSector,
AirDefenceIdentZone,
AlertArea,
AerialSportingOrRecreationalActivity,
AerodromeTrafficZone,
Airway,
ControlArea,
ControlZone,
Custom,
FlightInformationRegion,
FlightInformationServiceSector,
GlidingSector,
HelicopterTrafficZone,
LowerTrafficArea,
MilitaryAerodromeTrafficZone,
MilitaryTrainingArea,
MilitaryTrainingRoute,
NotamAffectedArea,
NoType,
OverflightRestriction,
ProhibitedArea,
DangerArea,
RestrictedArea,
RadioMandatoryZone,
TemporaryFlightRestriction,
TrafficInformationArea,
TrafficInformationZone,
TerminalManoeuvringArea,
TransponderMandatoryZone,
TemporaryReservedArea,
TemporaryReservedOrSegregatedAreaFeedingRoute,
TransponderRecommendedZone,
TemporarySegregatedArea,
UpperFlightInformationRegion,
UpperTrafficArea,
VisualFlightRulesRoute,
VisualFlightRulesSector,
WarningArea,
Unknown(Box<str>),
}
#[cfg(feature = "serde")]
impl serde::Serialize for AirspaceType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl AirspaceType {
pub fn parse(data: &str) -> Result<Self, String> {
if data.is_empty() {
return Err("Airspace type is empty".to_string());
}
let airspace_type = match data {
"ACCSEC" => Self::RemoteCommunicationSector,
"ADIZ" => Self::AirDefenceIdentZone,
"ALERT" => Self::AlertArea,
"ASRA" => Self::AerialSportingOrRecreationalActivity,
"ATZ" => Self::AerodromeTrafficZone,
"AWY" => Self::Airway,
"CTA" => Self::ControlArea,
"CTR" => Self::ControlZone,
"CUSTOM" => Self::Custom,
"FIR" => Self::FlightInformationRegion,
"FIS" => Self::FlightInformationServiceSector,
"GSEC" => Self::GlidingSector,
"HTZ" => Self::HelicopterTrafficZone,
"LTA" => Self::LowerTrafficArea,
"MATZ" => Self::MilitaryAerodromeTrafficZone,
"MTA" => Self::MilitaryTrainingArea,
"MTR" => Self::MilitaryTrainingRoute,
"N" => Self::NotamAffectedArea,
"NONE" => Self::NoType,
"OFR" => Self::OverflightRestriction,
"P" => Self::ProhibitedArea,
"Q" => Self::DangerArea,
"R" => Self::RestrictedArea,
"RMZ" => Self::RadioMandatoryZone,
"TFR" => Self::TemporaryFlightRestriction,
"TIA" => Self::TrafficInformationArea,
"TIZ" => Self::TrafficInformationZone,
"TMA" => Self::TerminalManoeuvringArea,
"TMZ" => Self::TransponderMandatoryZone,
"TRA" => Self::TemporaryReservedArea,
"TRAFR" => Self::TemporaryReservedOrSegregatedAreaFeedingRoute,
"TRZ" => Self::TransponderRecommendedZone,
"TSA" => Self::TemporarySegregatedArea,
"UIR" => Self::UpperFlightInformationRegion,
"UTA" => Self::UpperTrafficArea,
"VFRR" => Self::VisualFlightRulesRoute,
"VFRSEC" => Self::VisualFlightRulesSector,
"WARNING" => Self::WarningArea,
other => Self::Unknown(other.into()),
};
Ok(airspace_type)
}
pub fn as_str(&self) -> &str {
match self {
Self::RemoteCommunicationSector => "ACCSEC",
Self::AirDefenceIdentZone => "ADIZ",
Self::AlertArea => "ALERT",
Self::AerialSportingOrRecreationalActivity => "ASRA",
Self::AerodromeTrafficZone => "ATZ",
Self::Airway => "AWY",
Self::ControlArea => "CTA",
Self::ControlZone => "CTR",
Self::Custom => "CUSTOM",
Self::FlightInformationRegion => "FIR",
Self::FlightInformationServiceSector => "FIS",
Self::GlidingSector => "GSEC",
Self::HelicopterTrafficZone => "HTZ",
Self::LowerTrafficArea => "LTA",
Self::MilitaryAerodromeTrafficZone => "MATZ",
Self::MilitaryTrainingArea => "MTA",
Self::MilitaryTrainingRoute => "MTR",
Self::NotamAffectedArea => "N",
Self::NoType => "NONE",
Self::OverflightRestriction => "OFR",
Self::ProhibitedArea => "P",
Self::DangerArea => "Q",
Self::RestrictedArea => "R",
Self::RadioMandatoryZone => "RMZ",
Self::TemporaryFlightRestriction => "TFR",
Self::TrafficInformationArea => "TIA",
Self::TrafficInformationZone => "TIZ",
Self::TerminalManoeuvringArea => "TMA",
Self::TransponderMandatoryZone => "TMZ",
Self::TemporaryReservedArea => "TRA",
Self::TemporaryReservedOrSegregatedAreaFeedingRoute => "TRAFR",
Self::TransponderRecommendedZone => "TRZ",
Self::TemporarySegregatedArea => "TSA",
Self::UpperFlightInformationRegion => "UIR",
Self::UpperTrafficArea => "UTA",
Self::VisualFlightRulesRoute => "VFRR",
Self::VisualFlightRulesSector => "VFRSEC",
Self::WarningArea => "WARNING",
Self::Unknown(value) => value,
}
}
}