mod expand;
mod token;
use aerocontext_core::GeoPoint;
pub use expand::{expand, expand_str};
pub use token::parse;
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum RouteToken {
Ident(String),
Airway(String),
Dct,
LatLon(GeoPoint),
Procedure {
name: String,
transition: Option<String>,
},
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct RoutePoint {
pub ident: Option<String>,
pub position: GeoPoint,
pub via_airway: Option<String>,
}
impl RoutePoint {
pub fn new(position: GeoPoint) -> Self {
Self {
ident: None,
position,
via_airway: None,
}
}
#[must_use]
pub fn with_ident(mut self, ident: Option<String>) -> Self {
self.ident = ident;
self
}
#[must_use]
pub fn with_via_airway(mut self, via_airway: Option<String>) -> Self {
self.via_airway = via_airway;
self
}
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive]
pub struct ExpandedRoute {
pub points: Vec<RoutePoint>,
pub procedures: Vec<RouteToken>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum UnsupportedKind {
FixRadialDistance,
SpeedAltitudeChange,
SlashToken,
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum RouteError {
#[error("empty route string")]
Empty,
#[error("unsupported token {token:?} ({kind:?})")]
UnsupportedToken {
kind: UnsupportedKind,
token: String,
},
#[error("airway {airway} at the route edge needs an entry/exit fix")]
AirwayAtRouteEdge {
airway: String,
},
#[error("airways {first} and {second} are adjacent; name the transition fix between them")]
AdjacentAirways {
first: String,
second: String,
},
#[error("{ident} is not in the navigation snapshot (cycle effective {cycle})")]
UnresolvedIdent {
ident: String,
cycle: chrono::NaiveDate,
},
#[error("unknown airway {airway}")]
UnknownAirway {
airway: String,
},
#[error("{fix} is not on airway {airway} (entry)")]
EntryFixNotOnAirway {
fix: String,
airway: String,
},
#[error("{fix} is not on airway {airway} (exit)")]
ExitFixNotOnAirway {
fix: String,
airway: String,
},
#[error("airway {airway} is ambiguous between locations for {entry}..{exit}")]
AmbiguousAirway {
airway: String,
entry: String,
exit: String,
},
#[error("airway {airway} is discontinued between {from} and {to}")]
DiscontinuedSegment {
airway: String,
from: String,
to: String,
},
}
#[cfg(test)]
mod tests;