@squawk/procedures
Advanced tools
+11
-3
@@ -52,6 +52,14 @@ import type { Procedure, ProcedureType, ProcedureWaypoint } from '@squawk/types'; | ||
| * When called without a transition name, returns the first common route. | ||
| * When called with a transition name, returns the matching transition's | ||
| * waypoints followed by the first common route's waypoints (with any | ||
| * overlapping connecting fix deduplicated). | ||
| * | ||
| * When called with a transition name, the transition's waypoints are | ||
| * merged with the first common route's waypoints in flying order: | ||
| * - For STARs the transition feeds into the common route, so the | ||
| * transition waypoints come first followed by the common route. | ||
| * - For SIDs the common route departs the airport before joining the | ||
| * transition, so the common route comes first followed by the | ||
| * transition. | ||
| * | ||
| * In both cases the connecting fix where the transition meets the common | ||
| * route is deduplicated when present. | ||
| * | ||
| * Returns undefined if the procedure or transition is not found. | ||
@@ -58,0 +66,0 @@ */ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,iBAAiB,EAElB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,SAAS,EAAE,SAAS,CAAC;IACrB,4DAA4D;IAC5D,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAEpD;;;OAGG;IACH,SA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AAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,CAAC;IAEzC;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,CAAC;IAE5F;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,EAAE,CAAC;CAClD;AAOD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CA0G5F"} |
+15
-5
@@ -88,3 +88,3 @@ /** | ||
| } | ||
| const waypoints = mergeTransitionAndRoute(transition.waypoints, firstRoute); | ||
| const waypoints = mergeTransitionAndRoute(transition.waypoints, firstRoute, proc.type); | ||
| return { | ||
@@ -117,7 +117,9 @@ procedure: proc, | ||
| /** | ||
| * Merges a transition's waypoints with a common route's waypoints. | ||
| * If the last waypoint of the transition matches the first waypoint of the | ||
| * common route (by fix identifier), the duplicate is removed. | ||
| * Merges a transition's waypoints with a common route's waypoints in the | ||
| * order aircraft fly the procedure. SIDs depart along the common route and | ||
| * then continue onto the transition; STARs fly the transition into the | ||
| * common route. The connecting fix where the two segments meet is | ||
| * deduplicated when present. | ||
| */ | ||
| function mergeTransitionAndRoute(transitionWaypoints, route) { | ||
| function mergeTransitionAndRoute(transitionWaypoints, route, procedureType) { | ||
| if (transitionWaypoints.length === 0) { | ||
@@ -129,2 +131,10 @@ return route.waypoints; | ||
| } | ||
| if (procedureType === 'SID') { | ||
| const lastRoute = route.waypoints[route.waypoints.length - 1]; | ||
| const firstTransition = transitionWaypoints[0]; | ||
| if (lastRoute.fixIdentifier.toUpperCase() === firstTransition.fixIdentifier.toUpperCase()) { | ||
| return [...route.waypoints, ...transitionWaypoints.slice(1)]; | ||
| } | ||
| return [...route.waypoints, ...transitionWaypoints]; | ||
| } | ||
| const lastTransition = transitionWaypoints[transitionWaypoints.length - 1]; | ||
@@ -131,0 +141,0 @@ const firstRoute = route.waypoints[0]; |
+5
-4
| { | ||
| "name": "@squawk/procedures", | ||
| "version": "0.2.2", | ||
| "version": "0.2.3", | ||
| "type": "module", | ||
@@ -22,4 +22,4 @@ "description": "Instrument procedure lookup and expansion for SIDs and STARs", | ||
| ".": { | ||
| "import": "./dist/index.js", | ||
| "types": "./dist/index.d.ts" | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.js" | ||
| } | ||
@@ -34,3 +34,4 @@ }, | ||
| "test": "node --test 'dist/**/*.spec.js'", | ||
| "lint": "tsc --noEmit && eslint src" | ||
| "lint": "tsc --noEmit && eslint src", | ||
| "lint:pack": "publint && attw --pack . --profile esm-only" | ||
| }, | ||
@@ -37,0 +38,0 @@ "dependencies": { |
16126
6.68%250
7.76%