Pure logic library for querying US airway data. Look up airways by
designation, expand route segments between fixes, find airways through a
specific fix, or fuzzy-search by designation. Contains no bundled data - accepts
an array of Airway records at initialization. For zero-config use, pair with
@squawk/airway-data.
Part of the @squawk aviation library suite. See all packages on npm.
import { usBundledAirways } from '@squawk/airway-data';
import { createAirwayResolver } from '@squawk/airways';
const resolver = createAirwayResolver({ data: usBundledAirways.records });
// Look up by designation
const v16 = resolver.byDesignation('V16');
// Expand an airway between two fixes
const segment = resolver.expand('J70', 'SEA', 'GEP');
if (segment) {
for (const wp of segment.waypoints) {
console.log(wp.identifier, wp.minimumEnrouteAltitudeFt, 'ft MEA');
}
}
// Find all airways through a fix
const throughBos = resolver.byFix('BOS');
for (const result of throughBos) {
console.log(result.airway.designation);
}
// Fuzzy-search by designation (scored, best match first)
const results = resolver.search({ text: 'V1' });
console.log(results[0]?.airway.designation, results[0]?.score);
Consumers who have their own airway data can use this package standalone:
import { createAirwayResolver } from '@squawk/airways';
const resolver = createAirwayResolver({ data: myAirways });
The resolver factory has no Node-specific imports and ships an explicit /browser subpath for SPAs and edge runtimes. Pair it with @squawk/airway-data/browser:
import { loadUsBundledAirways } from '@squawk/airway-data/browser';
import { createAirwayResolver } from '@squawk/airways/browser';
const dataset = await loadUsBundledAirways();
const resolver = createAirwayResolver({ data: dataset.records });
The /browser entry is identical to the main entry.
createAirwayResolver(options)Creates a resolver object from an array of Airway records.
Parameters:
options.data - an array of Airway objects (from @squawk/types)Returns: AirwayResolver - an object with the lookup methods described below.
resolver.byDesignation(designation)Looks up airways by designation (e.g. "V16", "J60", "Q1"). Multiple airways
can share the same designation in different regions (e.g. V16 exists in both
the contiguous US and Hawaii). Case-insensitive. Returns Airway[].
resolver.expand(designation, entryFix, exitFix)Expands an airway between two fixes, returning the ordered sequence of
waypoints from the entry fix to the exit fix (inclusive). This is the
primary use case for flight plan route decoding - given a route string
like SEA J70 GEP, expand J70 between SEA and GEP.
Airways can be traversed in either direction. When the entry fix appears after the exit fix in the stored waypoint order, the returned waypoints are reversed so they always run entry-to-exit.
Returns AirwayExpansionResult | undefined. Returns undefined if:
The result contains:
airway - the full Airway recordwaypoints - the ordered slice of waypoints between the two fixesgaps - any published discontinuity inside the slice, each with the index of the waypoint before the gap and the from and to waypoint identifiers. The FAA discontinues some airways partway (J60 between JOT and DJB, for example); the waypoints on both sides are still returned, but a non-empty gaps means the airway is not defined between them and a route filing it across the gap is not valid as filedunusable - any segment inside the slice the FAA marks unusable, in the same index / from / to shape. An unusable segment (J34 between DRYER and GAABE, for example) is still published with its waypoints and distance but has no MEA and may not be flown, so a route filing the airway across it is not valid as filedreversed - whether the slice runs against the airway's published waypoint orderEach waypoint's segment fields (distanceToNextNm, the MEA, MAA, MOCA, GNSS
and DME/DME/IRU MEAs, the magnetic courses, the changeover point, and the
signal-gap, US-airspace-only and dogleg flags) describe the segment from that
waypoint to the next one in the airway's published order. In a reversed
expansion they therefore describe the segment between a waypoint and the one
before it in waypoints. gaps and unusable are already given in
traversal order.
The resolver returns every waypoint field as the FAA publishes it and does not
interpret any of them. It does not pick the MEA for the direction of flight: a
directional MEA, GNSS MEA or minimum crossing altitude carries its compass
direction (NE, SW, and so on) beside the value, and a route's direction
of flight has to be compared with it by the caller.
resolver.byFix(ident)Finds all airways that pass through a given fix or navaid identifier.
Case-insensitive. Returns AirwayByFixResult[], each containing:
airway - the Airway recordwaypointIndex - the index of the matching waypoint in the airwayresolver.search(query)Fuzzy-searches airways by designation. Matching is case-insensitive and tolerant of prefixes, substrings, subsequences, and small typos. Results are scored and returned best-match first.
| Property | Type | Description |
|---|---|---|
text |
string | Search text, matched fuzzily against each airway's designation |
limit |
number | Optional. Maximum number of results. Defaults to 20 |
types |
ReadonlySet<AirwayType> | Optional. When provided, only these airway types are returned |
minScore |
number | Optional. Minimum match score (exclusive) in [0, 1] a result must reach. Defaults to 0 |
Returns AirwaySearchResult[], sorted by descending score, each containing:
airway - the matched Airway recordscore - match strength in [0, 1], where 1 is an exact designation matchmatchedField - which field produced the best match: 'designation'ranges - matched character ranges within the best-matching field's text, for highlightingconst results = resolver.search({ text: 'V1', limit: 10 });
for (const { airway, score } of results) {
console.log(airway.designation, score);
}