New:Socket for Asana Is Now Available.Learn more
Sign In

@squawk/fixes

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squawk/fixes - npm Package Compare versions

Comparing version
0.4.0
to
0.5.0
+20
-0
dist/resolver.d.ts

@@ -75,2 +75,22 @@ import type { MatchRange } from '@squawk/search';

/**
* Looks up the single fix sharing the given identifier that lies nearest
* to a geographic position. The same fix identifier can be published in
* more than one ICAO region; this disambiguates the collision by proximity
* to a known point such as a map-click location or an adjacent route
* waypoint.
*
* Returns the nearest matching fix 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 fix carries the identifier.
*
* @param ident - Fix 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 fix, or `undefined` when none match or none fall within `toleranceNm`.
*/
byIdentAtPosition(ident: string, lat: number, lon: number, toleranceNm?: number): Fix | undefined;
/**
* Finds fixes nearest to a geographic position, sorted by distance.

@@ -77,0 +97,0 @@ * Results are filtered by max distance and limited to the requested count.

+1
-1

@@ -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,GAAG,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAA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AY,EAAE,cAAc,CAAC;IAC7B,wFAAwF;IACxF,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;IAE9B;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC;IAElG;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,EAAE,CAAC;IAEpD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,EAAE,CAAC;CAClD;AAiBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAuF1E"}

@@ -51,2 +51,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 fix of matches) {
const distNm = greatCircle.distanceNm(lat, lon, fix.lat, fix.lon);
if (distNm < nearestDistNm) {
nearest = fix;
nearestDistNm = distNm;
}
}
if (toleranceNm !== undefined && nearestDistNm > toleranceNm) {
return undefined;
}
return nearest;
},
nearest(query) {

@@ -53,0 +72,0 @@ const maxDist = query.maxDistanceNm ?? DEFAULT_MAX_DISTANCE_NM;

{
"name": "@squawk/fixes",
"version": "0.4.0",
"version": "0.5.0",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Fix/waypoint queries by identifier, location, or name search",

@@ -74,2 +74,24 @@ <h1><img src="../../../assets/squawk-logo.svg" alt="squawk logo" width="48" height="48" style="vertical-align: middle">&nbsp; @squawk/fixes</h1>

### `resolver.byIdentAtPosition(ident, lat, lon, toleranceNm?)`
Looks up the single fix sharing the given identifier that lies nearest to a
geographic position. The same fix identifier can be published in more than one
ICAO region; this disambiguates the collision by proximity to a known point such
as a map-click location or an adjacent route waypoint.
| Parameter | Type | Description |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------- |
| `ident` | string | Fix 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 `Fix` by great-circle distance, or `undefined` when
no fix carries the identifier or none fall within `toleranceNm`.
```typescript
// Disambiguate a shared identifier against an adjacent route waypoint
const fix = resolver.byIdentAtPosition('BOSCO', 40.64, -73.78);
```
### `resolver.nearest(query)`

@@ -76,0 +98,0 @@