@squawk/navaids
Advanced tools
+20
-0
@@ -86,2 +86,22 @@ import type { MatchRange } from '@squawk/search'; | ||
| /** | ||
| * Looks up the single navaid sharing the given identifier that lies | ||
| * nearest to a geographic position. Multiple navaids can publish the | ||
| * same identifier (a co-located NDB and VOR/DME, or two stations far | ||
| * apart that reuse a code); this disambiguates them by proximity to a | ||
| * known point such as a map-click location or an adjacent route waypoint. | ||
| * | ||
| * Returns the nearest matching navaid by great-circle distance. When | ||
| * `toleranceNm` is provided, matches farther than that distance are | ||
| * excluded and the method returns `undefined` if none qualify. When | ||
| * `toleranceNm` is omitted, the nearest match is returned regardless of | ||
| * distance. Returns `undefined` when no navaid carries the identifier. | ||
| * | ||
| * @param ident - Navaid identifier (case-insensitive). | ||
| * @param lat - Latitude of the reference position in decimal degrees (WGS84). | ||
| * @param lon - Longitude of the reference position in decimal degrees (WGS84). | ||
| * @param toleranceNm - Optional maximum great-circle distance in nautical miles. When omitted, the nearest match wins regardless of distance. | ||
| * @returns The nearest matching navaid, or `undefined` when none match or none fall within `toleranceNm`. | ||
| */ | ||
| byIdentAtPosition(ident: string, lat: number, lon: number, toleranceNm?: number): Navaid | undefined; | ||
| /** | ||
| * Finds navaids operating on a given frequency. | ||
@@ -88,0 +108,0 @@ * For VOR-family navaids, frequency is in MHz. For NDB-family, frequency is in kHz. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IA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;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,EAAE,CAAC;CACxD;AA2BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA0HnF"} |
+19
-0
@@ -61,2 +61,21 @@ import { greatCircle } from '@squawk/geo'; | ||
| }, | ||
| byIdentAtPosition(ident, lat, lon, toleranceNm) { | ||
| const matches = byIdentMap.get(ident.toUpperCase()); | ||
| if (matches === undefined || matches.length === 0) { | ||
| return undefined; | ||
| } | ||
| let nearest; | ||
| let nearestDistNm = Infinity; | ||
| for (const navaid of matches) { | ||
| const distNm = greatCircle.distanceNm(lat, lon, navaid.lat, navaid.lon); | ||
| if (distNm < nearestDistNm) { | ||
| nearest = navaid; | ||
| nearestDistNm = distNm; | ||
| } | ||
| } | ||
| if (toleranceNm !== undefined && nearestDistNm > toleranceNm) { | ||
| return undefined; | ||
| } | ||
| return nearest; | ||
| }, | ||
| byFrequency(query) { | ||
@@ -63,0 +82,0 @@ const limit = query.limit ?? DEFAULT_SEARCH_LIMIT; |
+1
-1
| { | ||
| "name": "@squawk/navaids", | ||
| "version": "0.5.0", | ||
| "version": "0.6.0", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Navaid queries by identifier, frequency, type, location, or name search", |
+23
-0
@@ -80,2 +80,25 @@ <h1><img src="../../../assets/squawk-logo.svg" alt="squawk logo" width="48" height="48" style="vertical-align: middle"> @squawk/navaids</h1> | ||
| ### `resolver.byIdentAtPosition(ident, lat, lon, toleranceNm?)` | ||
| Looks up the single navaid sharing the given identifier that lies nearest to a | ||
| geographic position. Multiple navaids can publish the same identifier (a | ||
| co-located NDB and VOR/DME, or two distant stations reusing a code); this | ||
| disambiguates them by proximity to a known point such as a map-click location or | ||
| an adjacent route waypoint. | ||
| | Parameter | Type | Description | | ||
| | ------------- | ------ | ------------------------------------------------------------------------------------------------------- | | ||
| | `ident` | string | Navaid identifier (case-insensitive) | | ||
| | `lat` | number | Latitude of the reference position in decimal degrees (WGS84) | | ||
| | `lon` | number | Longitude of the reference position in decimal degrees (WGS84) | | ||
| | `toleranceNm` | number | Optional. Maximum great-circle distance in nautical miles. Omit to let the nearest match win regardless | | ||
| Returns the nearest matching `Navaid` by great-circle distance, or `undefined` | ||
| when no navaid carries the identifier or none fall within `toleranceNm`. | ||
| ```typescript | ||
| // Disambiguate a shared identifier against a map-click position | ||
| const navaid = resolver.byIdentAtPosition('AA', 47.45, -122.31); | ||
| ``` | ||
| ### `resolver.byFrequency(query)` | ||
@@ -82,0 +105,0 @@ |
24313
18.42%299
15%178
14.84%