airport-dist 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,7 +23,7 @@ airport-dist -f LHR -t DXB
23
23
  The tool provides two distance measurements:
24
24
 
25
25
  1. **Geographical Distance** - Great circle (Haversine) distance, the shortest path between two points on Earth
26
- 2. **Aviation Route Distance** - Estimated actual flight distance accounting for airways, waypoints, and routing factors
26
+ 2. **Aviation Route Distance** - Actual airline route distance from bundled route database (55,000+ routes)
27
27
 
28
28
  ```
29
29
  Calculating distances from JFK to LAX...
@@ -42,10 +42,10 @@ DISTANCE RESULTS
42
42
  2145.97 nautical miles
43
43
 
44
44
  2. AVIATION ROUTE DISTANCE:
45
- 4173.05 km
46
- 2593.01 miles
47
- 2253.27 nautical miles
48
- Source: Calculated (Great Circle + industry routing factors)
45
+ 3982.00 km
46
+ 2474.30 miles
47
+ 2150.11 nautical miles
48
+ Source: Airline route data (bundled)
49
49
 
50
50
  ============================================================
51
51
 
@@ -62,18 +62,17 @@ airways, restricted airspace, weather patterns, and traffic flow.
62
62
  | `--version` | `-V` | Show version number |
63
63
  | `--help` | `-h` | Show help |
64
64
 
65
- ## Supported Airports
65
+ ## Data Sources
66
66
 
67
- The tool includes a built-in database of 150+ major international airports. If an airport is not in the database, it will attempt to fetch the data from a public API.
67
+ - **Airport Database**: 150+ major international airports with coordinates
68
+ - **Route Database**: 55,000+ airline routes with actual distances from [Jonty/airline-route-data](https://github.com/Jonty/airline-route-data)
69
+ - **Fallback**: Estimation using industry-standard routing factors when route not in database
68
70
 
69
71
  ## How It Works
70
72
 
71
73
  - **Geographical Distance**: Calculated using the Haversine formula, which determines the great-circle distance between two points on a sphere given their latitudes and longitudes.
72
74
 
73
- - **Aviation Route Distance**: Estimated using industry-standard routing factors that account for:
74
- - Airways and waypoint requirements
75
- - Departure/arrival procedures (SIDs/STARs)
76
- - Distance-based overhead (shorter flights have proportionally higher overhead)
75
+ - **Aviation Route Distance**: Sourced from bundled airline route data containing actual flight distances. Falls back to estimation for routes not in the database.
77
76
 
78
77
  ## License
79
78
 
@@ -1,13 +1,7 @@
1
1
  /**
2
2
  * Aviation route distance module.
3
- * Calculates estimated flight route distances based on industry-standard factors.
4
- *
5
- * Aviation routes differ from great circle distances due to:
6
- * - Airways and waypoint requirements
7
- * - Restricted airspace avoidance
8
- * - Departure/arrival procedures (SIDs/STARs)
9
- * - Jet streams and wind optimization
10
- * - Traffic flow management
3
+ * Uses bundled airline route data from https://github.com/Jonty/airline-route-data
4
+ * Falls back to estimation when route is not in database.
11
5
  */
12
6
  import { Distance } from "./haversine";
13
7
  export interface AviationDistance extends Distance {
@@ -15,7 +9,7 @@ export interface AviationDistance extends Distance {
15
9
  }
16
10
  /**
17
11
  * Get the aviation route distance between two airports.
18
- * Uses industry-standard routing factors to estimate actual flight distance.
12
+ * First checks bundled route database, then falls back to estimation.
19
13
  */
20
14
  export declare function getAviationRouteDistance(fromIata: string, toIata: string, geoDistance: Distance): AviationDistance;
21
15
  //# sourceMappingURL=aviation-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aviation-api.d.ts","sourceRoot":"","sources":["../src/aviation-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,QAAQ,GACpB,gBAAgB,CASlB"}
1
+ {"version":3,"file":"aviation-api.d.ts","sourceRoot":"","sources":["../src/aviation-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,QAAQ,GACpB,gBAAgB,CAoClB"}
@@ -1,96 +1,70 @@
1
1
  "use strict";
2
2
  /**
3
3
  * Aviation route distance module.
4
- * Calculates estimated flight route distances based on industry-standard factors.
5
- *
6
- * Aviation routes differ from great circle distances due to:
7
- * - Airways and waypoint requirements
8
- * - Restricted airspace avoidance
9
- * - Departure/arrival procedures (SIDs/STARs)
10
- * - Jet streams and wind optimization
11
- * - Traffic flow management
4
+ * Uses bundled airline route data from https://github.com/Jonty/airline-route-data
5
+ * Falls back to estimation when route is not in database.
12
6
  */
13
7
  Object.defineProperty(exports, "__esModule", { value: true });
14
8
  exports.getAviationRouteDistance = getAviationRouteDistance;
9
+ const route_data_1 = require("./route-data");
15
10
  const KM_TO_MILES = 0.621371;
16
11
  const KM_TO_NAUTICAL_MILES = 0.539957;
17
12
  /**
18
13
  * Get the aviation route distance between two airports.
19
- * Uses industry-standard routing factors to estimate actual flight distance.
14
+ * First checks bundled route database, then falls back to estimation.
20
15
  */
21
16
  function getAviationRouteDistance(fromIata, toIata, geoDistance) {
22
- const estimatedKm = estimateAviationDistance(geoDistance.km, fromIata, toIata);
17
+ // Try to find route in bundled database
18
+ const routeKey = `${fromIata}-${toIata}`;
19
+ const bundledDistance = route_data_1.ROUTE_DISTANCES[routeKey];
20
+ if (bundledDistance) {
21
+ return {
22
+ km: bundledDistance,
23
+ miles: bundledDistance * KM_TO_MILES,
24
+ nauticalMiles: bundledDistance * KM_TO_NAUTICAL_MILES,
25
+ source: "Airline route data (bundled)",
26
+ };
27
+ }
28
+ // Try reverse route (some routes may only be listed one direction)
29
+ const reverseKey = `${toIata}-${fromIata}`;
30
+ const reverseDistance = route_data_1.ROUTE_DISTANCES[reverseKey];
31
+ if (reverseDistance) {
32
+ return {
33
+ km: reverseDistance,
34
+ miles: reverseDistance * KM_TO_MILES,
35
+ nauticalMiles: reverseDistance * KM_TO_NAUTICAL_MILES,
36
+ source: "Airline route data (bundled)",
37
+ };
38
+ }
39
+ // Fallback to estimation
40
+ const estimatedKm = estimateAviationDistance(geoDistance.km);
23
41
  return {
24
42
  km: estimatedKm,
25
43
  miles: estimatedKm * KM_TO_MILES,
26
44
  nauticalMiles: estimatedKm * KM_TO_NAUTICAL_MILES,
27
- source: "Calculated (Great Circle + industry routing factors)",
45
+ source: "Estimated (Great Circle + routing factors)",
28
46
  };
29
47
  }
30
48
  /**
31
- * Known route corrections for specific airport pairs.
32
- * These are based on published flight distances from airlines and aviation authorities.
33
- * Values represent the multiplier to apply to great circle distance.
49
+ * Estimate aviation distance when not in bundled database.
50
+ * Based on industry-standard routing overhead factors.
34
51
  */
35
- const ROUTE_CORRECTIONS = {
36
- // Transatlantic routes (North Atlantic Tracks add distance)
37
- "JFK-LHR": 1.02,
38
- "LHR-JFK": 1.02,
39
- "LAX-LHR": 1.03,
40
- "LHR-LAX": 1.03,
41
- // Transpacific routes
42
- "LAX-NRT": 1.02,
43
- "NRT-LAX": 1.02,
44
- "SFO-HKG": 1.03,
45
- "HKG-SFO": 1.03,
46
- // Routes avoiding restricted airspace
47
- "LHR-SIN": 1.04,
48
- "SIN-LHR": 1.04,
49
- "DXB-JFK": 1.03,
50
- "JFK-DXB": 1.03,
51
- };
52
- /**
53
- * Estimate aviation distance based on great circle distance and routing factors.
54
- *
55
- * The estimation uses several factors:
56
- * 1. Base routing overhead (airways, waypoints)
57
- * 2. Distance-based adjustments (short flights have proportionally more overhead)
58
- * 3. Known route corrections for specific airport pairs
59
- */
60
- function estimateAviationDistance(greatCircleKm, fromIata, toIata) {
61
- // Check for known route corrections first
62
- const routeKey = `${fromIata}-${toIata}`;
63
- const knownCorrection = ROUTE_CORRECTIONS[routeKey];
64
- if (knownCorrection) {
65
- return greatCircleKm * knownCorrection;
66
- }
67
- // Calculate base factor based on distance
68
- // Industry data shows:
69
- // - Very short flights (<500km): ~10% overhead due to SID/STAR procedures
70
- // - Short flights (500-1500km): ~7% overhead
71
- // - Medium flights (1500-5000km): ~5% overhead
72
- // - Long-haul flights (5000-10000km): ~4% overhead
73
- // - Ultra long-haul (>10000km): ~3% overhead (more optimized routing)
52
+ function estimateAviationDistance(greatCircleKm) {
74
53
  let factor;
75
54
  if (greatCircleKm < 500) {
76
- // Very short flights - significant overhead from departure/arrival procedures
77
- factor = 1.10;
55
+ factor = 1.10; // 10% overhead for very short flights
78
56
  }
79
57
  else if (greatCircleKm < 1500) {
80
- // Short regional flights
81
- factor = 1.07;
58
+ factor = 1.07; // 7% for short regional flights
82
59
  }
83
60
  else if (greatCircleKm < 5000) {
84
- // Medium-haul flights
85
- factor = 1.05;
61
+ factor = 1.05; // 5% for medium-haul
86
62
  }
87
63
  else if (greatCircleKm < 10000) {
88
- // Long-haul flights - more optimized but still need to follow airways
89
- factor = 1.04;
64
+ factor = 1.04; // 4% for long-haul
90
65
  }
91
66
  else {
92
- // Ultra long-haul - highly optimized great circle routing
93
- factor = 1.03;
67
+ factor = 1.03; // 3% for ultra long-haul
94
68
  }
95
69
  return greatCircleKm * factor;
96
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"aviation-api.js","sourceRoot":"","sources":["../src/aviation-api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAeH,4DAaC;AAxBD,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAMtC;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,QAAgB,EAChB,MAAc,EACd,WAAqB;IAErB,MAAM,WAAW,GAAG,wBAAwB,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE/E,OAAO;QACL,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,WAAW,GAAG,WAAW;QAChC,aAAa,EAAE,WAAW,GAAG,oBAAoB;Q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BAAoB;QACjD,MAAM,EAAE,4CAA4C;KACrD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,wBAAwB,CAAC,aAAqB;IACrD,IAAI,MAAc,CAAC;IAEnB,IAAI,aAAa,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,GAAG,IAAI,CAAC,CAAC,sCAAsC;IACvD,CAAC;SAAM,IAAI,aAAa,GAAG,IAAI,EAAE,CAAC;QAChC,MAAM,GAAG,IAAI,CAAC,CAAC,gCAAgC;IACjD,CAAC;SAAM,IAAI,aAAa,GAAG,IAAI,EAAE,CAAC;QAChC,MAAM,GAAG,IAAI,CAAC,CAAC,qBAAqB;IACtC,CAAC;SAAM,IAAI,aAAa,GAAG,KAAK,EAAE,CAAC;QACjC,MAAM,GAAG,IAAI,CAAC,CAAC,mBAAmB;IACpC,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,IAAI,CAAC,CAAC,yBAAyB;IAC1C,CAAC;IAED,OAAO,aAAa,GAAG,MAAM,CAAC;AAChC,CAAC"}
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ const program = new commander_1.Command();
9
9
  program
10
10
  .name("airport-dist")
11
11
  .description("Calculate geographical and aviation route distances between airports")
12
- .version("1.0.0")
12
+ .version("1.1.1")
13
13
  .requiredOption("-f, --from <code>", "Origin airport IATA code (e.g., JFK)")
14
14
  .requiredOption("-t, --to <code>", "Destination airport IATA code (e.g., LAX)")
15
15
  .action(async (options) => {
@@ -0,0 +1,2 @@
1
+ export declare const ROUTE_DISTANCES: Record<string, number>;
2
+ //# sourceMappingURL=route-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-data.d.ts","sourceRoot":"","sources":["../src/route-data.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAko0xB,CAAC"}