@dangahagan/weather-mcp 1.40.0 → 1.40.2
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 +3 -3
- package/dist/config/cache.d.ts +1 -0
- package/dist/config/cache.d.ts.map +1 -1
- package/dist/config/cache.js +5 -0
- package/dist/config/cache.js.map +1 -1
- package/dist/handlers/aviationWeatherHandler.d.ts.map +1 -1
- package/dist/handlers/aviationWeatherHandler.js +15 -0
- package/dist/handlers/aviationWeatherHandler.js.map +1 -1
- package/dist/handlers/tropicalCycloneContext.d.ts +32 -0
- package/dist/handlers/tropicalCycloneContext.d.ts.map +1 -0
- package/dist/handlers/tropicalCycloneContext.js +99 -0
- package/dist/handlers/tropicalCycloneContext.js.map +1 -0
- package/dist/services/aviationWeather.d.ts +4 -2
- package/dist/services/aviationWeather.d.ts.map +1 -1
- package/dist/services/aviationWeather.js +7 -3
- package/dist/services/aviationWeather.js.map +1 -1
- package/dist/services/nhc.d.ts +56 -0
- package/dist/services/nhc.d.ts.map +1 -0
- package/dist/services/nhc.js +196 -0
- package/dist/services/nhc.js.map +1 -0
- package/dist/types/nhc.d.ts +74 -0
- package/dist/types/nhc.d.ts.map +1 -0
- package/dist/types/nhc.js +16 -0
- package/dist/types/nhc.js.map +1 -0
- package/dist/utils/jmaParse.js +1 -1
- package/dist/utils/jmaParse.js.map +1 -1
- package/dist/utils/kmz.d.ts +55 -0
- package/dist/utils/kmz.d.ts.map +1 -0
- package/dist/utils/kmz.js +161 -0
- package/dist/utils/kmz.js.map +1 -0
- package/dist/utils/serviceStatusCoverage.d.ts.map +1 -1
- package/dist/utils/serviceStatusCoverage.js +1 -0
- package/dist/utils/serviceStatusCoverage.js.map +1 -1
- package/dist/utils/spcOutlook.js +1 -1
- package/dist/utils/spcOutlook.js.map +1 -1
- package/dist/utils/tafForecast.d.ts +2 -2
- package/dist/utils/tafForecast.js +2 -2
- package/dist/utils/tropicalCyclones.d.ts +123 -0
- package/dist/utils/tropicalCyclones.d.ts.map +1 -0
- package/dist/utils/tropicalCyclones.js +439 -0
- package/dist/utils/tropicalCyclones.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NHC active-storm feed parsing, forecast-cone KML parsing and containment.
|
|
3
|
+
*
|
|
4
|
+
* Pure and I/O-free. The service fetches, this module narrows. Every guard
|
|
5
|
+
* here either skips one bad record (a sibling is still usable) or throws (the
|
|
6
|
+
* whole answer is unusable): a feed that is not the expected envelope is never
|
|
7
|
+
* read as "no storms" (G4), and a cone that cannot be read is a cone failure,
|
|
8
|
+
* never a cone that happens not to contain the point.
|
|
9
|
+
*/
|
|
10
|
+
import { XMLParser, XMLValidator } from 'fast-xml-parser';
|
|
11
|
+
import { pointInRing } from './pointInPolygon.js';
|
|
12
|
+
import { bearingDegrees, calculateDistance, compassPoint, kmToMiles } from './distance.js';
|
|
13
|
+
import { formatInTimezoneWithZone } from './timezone.js';
|
|
14
|
+
/** Largest answer the service accepts, feed or cone: 1 MiB (measured: 19 KB cone, 15 KB four-storm feed). */
|
|
15
|
+
export const NHC_MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
16
|
+
/** Records kept from one feed; the cap removes lines only and backs no claim. */
|
|
17
|
+
export const NHC_MAX_STORMS = 30;
|
|
18
|
+
/** Vertices accepted in one cone ring. A trimmed polygon changes containment, so over the cap is a refusal. */
|
|
19
|
+
export const NHC_MAX_RING_VERTICES = 20_000;
|
|
20
|
+
/** Rings accepted in one cone file. */
|
|
21
|
+
export const NHC_MAX_RINGS = 16;
|
|
22
|
+
/**
|
|
23
|
+
* Deepest `Document`/`Folder` nesting read in one cone file (the `kml` root is 0; a real NHC cone is
|
|
24
|
+
* `Document`→`Placemark`, depth 1). A deeper file is refused like the other caps, never read in part:
|
|
25
|
+
* skipping a deeper polygon would be a silent trim (diff-review codex-M1).
|
|
26
|
+
*/
|
|
27
|
+
export const KML_MAX_FOLDER_DEPTH = 8;
|
|
28
|
+
/** Minimum vertices of a usable ring (a closed triangle). */
|
|
29
|
+
const MIN_RING_VERTICES = 4;
|
|
30
|
+
/** Size guard for the KML text, after inflation (the KMZ reader caps inflation at 4 MiB). */
|
|
31
|
+
const MAX_KML_CHARS = 4 * 1024 * 1024;
|
|
32
|
+
/**
|
|
33
|
+
* The only cone URL form the service will request. It lives here and not in
|
|
34
|
+
* the service because the status drift guard scans every `scheme://host`
|
|
35
|
+
* literal in `src/services/*.ts`, comments included.
|
|
36
|
+
*/
|
|
37
|
+
export const NHC_CONE_URL_RE = /^https:\/\/www\.nhc\.noaa\.gov\/storm_graphics\/api\/[A-Z]{2}\d{6}_\d{3}A?adv_CONE\.kmz$/;
|
|
38
|
+
/** True when `url` is a string naming an NHC forecast-cone KMZ in the one accepted form. */
|
|
39
|
+
export function isNhcConeUrl(url) {
|
|
40
|
+
return typeof url === 'string' && NHC_CONE_URL_RE.test(url);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The file name of an accepted cone URL (`AL092024_016Aadv_CONE.kmz`), or
|
|
44
|
+
* `undefined` when the URL is not accepted. Used as a cache-key component
|
|
45
|
+
* instead of the URL, which holds `:` (G5).
|
|
46
|
+
*/
|
|
47
|
+
export function coneFileName(url) {
|
|
48
|
+
if (!isNhcConeUrl(url))
|
|
49
|
+
return undefined;
|
|
50
|
+
return url.slice(url.lastIndexOf('/') + 1);
|
|
51
|
+
}
|
|
52
|
+
function isPlainObject(value) {
|
|
53
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
54
|
+
}
|
|
55
|
+
const DECIMAL_RE = /^[+-]?(\d+(\.\d*)?|\.\d+)$/;
|
|
56
|
+
/**
|
|
57
|
+
* A finite number, or a plain decimal string that reads as one; anything else
|
|
58
|
+
* is `undefined`. Refuses `''`, `'NaN'`, `'Infinity'`, hex, exponents and
|
|
59
|
+
* objects. NHC publishes `intensity` and `pressure` as strings.
|
|
60
|
+
*/
|
|
61
|
+
export function parseNhcNumber(value) {
|
|
62
|
+
if (typeof value === 'number') {
|
|
63
|
+
return Number.isFinite(value) ? value : undefined;
|
|
64
|
+
}
|
|
65
|
+
if (typeof value === 'string') {
|
|
66
|
+
const trimmed = value.trim();
|
|
67
|
+
if (!DECIMAL_RE.test(trimmed))
|
|
68
|
+
return undefined;
|
|
69
|
+
const n = Number(trimmed);
|
|
70
|
+
return Number.isFinite(n) ? n : undefined;
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
function stringField(value) {
|
|
75
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
76
|
+
}
|
|
77
|
+
function nestedString(parent, key) {
|
|
78
|
+
return isPlainObject(parent) ? stringField(parent[key]) : undefined;
|
|
79
|
+
}
|
|
80
|
+
/** Read one raw record; `undefined` when it lacks an id or a usable centre. */
|
|
81
|
+
function readStorm(raw) {
|
|
82
|
+
if (!isPlainObject(raw))
|
|
83
|
+
return undefined;
|
|
84
|
+
const id = stringField(raw.id);
|
|
85
|
+
const latitude = raw.latitudeNumeric;
|
|
86
|
+
const longitude = raw.longitudeNumeric;
|
|
87
|
+
if (id === undefined)
|
|
88
|
+
return undefined;
|
|
89
|
+
if (typeof latitude !== 'number' || !Number.isFinite(latitude) || latitude < -90 || latitude > 90) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (typeof longitude !== 'number' || !Number.isFinite(longitude) || longitude < -180 || longitude > 180) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
const storm = { id, latitude, longitude };
|
|
96
|
+
const name = stringField(raw.name);
|
|
97
|
+
if (name !== undefined)
|
|
98
|
+
storm.name = name;
|
|
99
|
+
const classification = stringField(raw.classification);
|
|
100
|
+
if (classification !== undefined)
|
|
101
|
+
storm.classification = classification;
|
|
102
|
+
const intensityKt = parseNhcNumber(raw.intensity);
|
|
103
|
+
if (intensityKt !== undefined)
|
|
104
|
+
storm.intensityKt = intensityKt;
|
|
105
|
+
const pressureMb = parseNhcNumber(raw.pressure);
|
|
106
|
+
if (pressureMb !== undefined)
|
|
107
|
+
storm.pressureMb = pressureMb;
|
|
108
|
+
const movementDir = parseNhcNumber(raw.movementDir);
|
|
109
|
+
if (movementDir !== undefined)
|
|
110
|
+
storm.movementDir = movementDir;
|
|
111
|
+
const movementSpeedMph = parseNhcNumber(raw.movementSpeed);
|
|
112
|
+
if (movementSpeedMph !== undefined)
|
|
113
|
+
storm.movementSpeedMph = movementSpeedMph;
|
|
114
|
+
const lastUpdate = stringField(raw.lastUpdate);
|
|
115
|
+
if (lastUpdate !== undefined)
|
|
116
|
+
storm.lastUpdate = lastUpdate;
|
|
117
|
+
const advisoryNumber = nestedString(raw.publicAdvisory, 'advNum');
|
|
118
|
+
if (advisoryNumber !== undefined)
|
|
119
|
+
storm.advisoryNumber = advisoryNumber;
|
|
120
|
+
const advisoryIssued = nestedString(raw.publicAdvisory, 'issuance');
|
|
121
|
+
if (advisoryIssued !== undefined)
|
|
122
|
+
storm.advisoryIssued = advisoryIssued;
|
|
123
|
+
const coneUrl = nestedString(raw.trackCone, 'kmzFile');
|
|
124
|
+
if (coneUrl !== undefined)
|
|
125
|
+
storm.coneUrl = coneUrl;
|
|
126
|
+
return storm;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Parse the decoded `CurrentStorms.json` body.
|
|
130
|
+
*
|
|
131
|
+
* An envelope that is not an object with an `activeStorms` array throws (an
|
|
132
|
+
* empty string, `null`, `{}`, an HTML page, `{ activeStorms: {} }`): a quiet
|
|
133
|
+
* ocean is `activeStorms: []`, and nothing else is read as one (G4, G111). A
|
|
134
|
+
* record without a string id or an in-range numeric centre is skipped and its
|
|
135
|
+
* siblings are kept.
|
|
136
|
+
*/
|
|
137
|
+
export function parseCurrentStorms(body) {
|
|
138
|
+
if (!isPlainObject(body) || !Array.isArray(body.activeStorms)) {
|
|
139
|
+
throw new Error('NHC storm feed returned an unexpected shape');
|
|
140
|
+
}
|
|
141
|
+
const storms = [];
|
|
142
|
+
let trimmed = false;
|
|
143
|
+
for (const raw of body.activeStorms) {
|
|
144
|
+
const storm = readStorm(raw);
|
|
145
|
+
if (storm === undefined)
|
|
146
|
+
continue;
|
|
147
|
+
if (storms.length >= NHC_MAX_STORMS) {
|
|
148
|
+
trimmed = true;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
storms.push(storm);
|
|
152
|
+
}
|
|
153
|
+
return { storms, trimmed };
|
|
154
|
+
}
|
|
155
|
+
/** One `XMLParser`, configured once. Entities are off: nothing in a cone needs one. */
|
|
156
|
+
const kmlParser = new XMLParser({
|
|
157
|
+
removeNSPrefix: true,
|
|
158
|
+
ignoreAttributes: true,
|
|
159
|
+
parseTagValue: false,
|
|
160
|
+
trimValues: true,
|
|
161
|
+
processEntities: false,
|
|
162
|
+
isArray: (name) => name === 'Document' || name === 'Folder' || name === 'Placemark' || name === 'Polygon'
|
|
163
|
+
});
|
|
164
|
+
const KML_UNREADABLE = 'NHC cone file is not usable';
|
|
165
|
+
function asArray(value) {
|
|
166
|
+
if (value === undefined)
|
|
167
|
+
return [];
|
|
168
|
+
return Array.isArray(value) ? value : [value];
|
|
169
|
+
}
|
|
170
|
+
function readCoordinates(text) {
|
|
171
|
+
if (typeof text !== 'string')
|
|
172
|
+
throw new Error(KML_UNREADABLE);
|
|
173
|
+
const tuples = text.split(/\s+/).filter(part => part !== '');
|
|
174
|
+
if (tuples.length > NHC_MAX_RING_VERTICES)
|
|
175
|
+
throw new Error(KML_UNREADABLE);
|
|
176
|
+
const ring = [];
|
|
177
|
+
for (const tuple of tuples) {
|
|
178
|
+
const parts = tuple.split(',');
|
|
179
|
+
if (parts.length < 2 || parts.length > 3)
|
|
180
|
+
throw new Error(KML_UNREADABLE);
|
|
181
|
+
const lon = parseNhcNumber(parts[0]);
|
|
182
|
+
const lat = parseNhcNumber(parts[1]);
|
|
183
|
+
if (parts.length === 3 && parseNhcNumber(parts[2]) === undefined)
|
|
184
|
+
throw new Error(KML_UNREADABLE);
|
|
185
|
+
if (lon === undefined || lat === undefined)
|
|
186
|
+
throw new Error(KML_UNREADABLE);
|
|
187
|
+
if (lat < -90 || lat > 90 || !(lon > -360 && lon <= 360))
|
|
188
|
+
throw new Error(KML_UNREADABLE);
|
|
189
|
+
ring.push([lat, lon]);
|
|
190
|
+
}
|
|
191
|
+
if (ring.length < MIN_RING_VERTICES)
|
|
192
|
+
throw new Error(KML_UNREADABLE);
|
|
193
|
+
return ring;
|
|
194
|
+
}
|
|
195
|
+
function collectPolygons(node, into, depth) {
|
|
196
|
+
if (!isPlainObject(node))
|
|
197
|
+
return;
|
|
198
|
+
if (depth > KML_MAX_FOLDER_DEPTH)
|
|
199
|
+
throw new Error(KML_UNREADABLE);
|
|
200
|
+
for (const placemark of asArray(node.Placemark)) {
|
|
201
|
+
if (!isPlainObject(placemark))
|
|
202
|
+
continue;
|
|
203
|
+
for (const polygon of asArray(placemark.Polygon)) {
|
|
204
|
+
if (isPlainObject(polygon))
|
|
205
|
+
into.push(polygon);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
for (const polygon of asArray(node.Polygon)) {
|
|
209
|
+
if (isPlainObject(polygon))
|
|
210
|
+
into.push(polygon);
|
|
211
|
+
}
|
|
212
|
+
for (const folder of asArray(node.Folder))
|
|
213
|
+
collectPolygons(folder, into, depth + 1);
|
|
214
|
+
for (const doc of asArray(node.Document))
|
|
215
|
+
collectPolygons(doc, into, depth + 1);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Parse a cone KML into outer rings in `[lat, lon]` order (the order
|
|
219
|
+
* `pointInRing` takes; KML stores `lon,lat`).
|
|
220
|
+
*
|
|
221
|
+
* Throws, with one fixed message, on anything it does not recognise: a DOCTYPE,
|
|
222
|
+
* malformed or multi-root XML, a Polygon with `innerBoundaryIs`, a non-finite
|
|
223
|
+
* or out-of-range tuple, a ring over 20,000 vertices, more than 16 rings, or no
|
|
224
|
+
* polygon at all. A trimmed polygon would change containment, so over-cap input
|
|
225
|
+
* is refused and never cut. A thrown cone is a cone failure, which only drops
|
|
226
|
+
* a sentence at the render.
|
|
227
|
+
*/
|
|
228
|
+
export function parseConeKml(kml) {
|
|
229
|
+
if (typeof kml !== 'string' || kml.length > MAX_KML_CHARS)
|
|
230
|
+
throw new Error(KML_UNREADABLE);
|
|
231
|
+
const stripped = kml.replace(/^\uFEFF/, '').trimStart();
|
|
232
|
+
if (/<!DOCTYPE/i.test(stripped))
|
|
233
|
+
throw new Error(KML_UNREADABLE);
|
|
234
|
+
if (XMLValidator.validate(stripped) !== true)
|
|
235
|
+
throw new Error(KML_UNREADABLE);
|
|
236
|
+
let parsed;
|
|
237
|
+
try {
|
|
238
|
+
parsed = kmlParser.parse(stripped);
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
throw new Error(KML_UNREADABLE);
|
|
242
|
+
}
|
|
243
|
+
if (!isPlainObject(parsed))
|
|
244
|
+
throw new Error(KML_UNREADABLE);
|
|
245
|
+
// Exactly one non-PI root, not an array (G3), and it is `kml`.
|
|
246
|
+
const rootKeys = Object.keys(parsed).filter(key => !key.startsWith('?'));
|
|
247
|
+
if (rootKeys.length !== 1 || rootKeys[0] !== 'kml' || Array.isArray(parsed.kml)) {
|
|
248
|
+
throw new Error(KML_UNREADABLE);
|
|
249
|
+
}
|
|
250
|
+
const polygons = [];
|
|
251
|
+
collectPolygons(parsed.kml, polygons, 0);
|
|
252
|
+
if (polygons.length === 0 || polygons.length > NHC_MAX_RINGS)
|
|
253
|
+
throw new Error(KML_UNREADABLE);
|
|
254
|
+
const rings = [];
|
|
255
|
+
for (const polygon of polygons) {
|
|
256
|
+
if (polygon.innerBoundaryIs !== undefined)
|
|
257
|
+
throw new Error(KML_UNREADABLE);
|
|
258
|
+
const outer = polygon.outerBoundaryIs;
|
|
259
|
+
if (!isPlainObject(outer) || !isPlainObject(outer.LinearRing))
|
|
260
|
+
throw new Error(KML_UNREADABLE);
|
|
261
|
+
rings.push(readCoordinates(outer.LinearRing.coordinates));
|
|
262
|
+
}
|
|
263
|
+
return rings;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Whether the point is inside any ring of a cone, across the antimeridian.
|
|
267
|
+
*
|
|
268
|
+
* A ring whose longitude span exceeds 180 degrees crosses +/-180, so its
|
|
269
|
+
* negative longitudes gain 360 (the `aviationHazards.ts` normalisation). The
|
|
270
|
+
* point is then tested at `lon`, `lon + 360` and `lon - 360`, so it matches
|
|
271
|
+
* whichever side of the date line the caller's longitude falls on. Rings that
|
|
272
|
+
* enclose a pole are a stated non-case: a cone never encloses one.
|
|
273
|
+
* `pointInPolygon.ts` has no wrap handling and is not edited.
|
|
274
|
+
*/
|
|
275
|
+
export function pointInCone(lat, lon, rings) {
|
|
276
|
+
for (const ring of rings) {
|
|
277
|
+
let minLon = Infinity;
|
|
278
|
+
let maxLon = -Infinity;
|
|
279
|
+
for (const [, vertexLon] of ring) {
|
|
280
|
+
if (vertexLon < minLon)
|
|
281
|
+
minLon = vertexLon;
|
|
282
|
+
if (vertexLon > maxLon)
|
|
283
|
+
maxLon = vertexLon;
|
|
284
|
+
}
|
|
285
|
+
const unwrapped = maxLon - minLon > 180
|
|
286
|
+
? ring.map(([vLat, vLon]) => [vLat, vLon < 0 ? vLon + 360 : vLon])
|
|
287
|
+
: ring;
|
|
288
|
+
for (const candidate of [lon, lon + 360, lon - 360]) {
|
|
289
|
+
if (pointInRing(lat, candidate, unwrapped))
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
// ---------------------------------------------------------------------------
|
|
296
|
+
// Qualification, staleness and the rendered line (GD1-GD3)
|
|
297
|
+
// ---------------------------------------------------------------------------
|
|
298
|
+
/** A storm whose centre is this near (km, inclusive) qualifies without a cone. */
|
|
299
|
+
export const TROPICAL_CONTEXT_RADIUS_KM = 1000;
|
|
300
|
+
/** A record older than this (ms) is a dead feed and is skipped: 24 hours. */
|
|
301
|
+
export const NHC_MAX_RECORD_AGE_MS = 24 * 60 * 60 * 1000;
|
|
302
|
+
/**
|
|
303
|
+
* Whether a storm qualifies for the point, and the facts the line needs.
|
|
304
|
+
* Qualifies when the centre is within 1,000 km (inclusive) or the cone
|
|
305
|
+
* contains the point; otherwise `null`.
|
|
306
|
+
*/
|
|
307
|
+
export function qualifies(storm, latitude, longitude, coneOutcome) {
|
|
308
|
+
const distanceKm = calculateDistance(latitude, longitude, storm.latitude, storm.longitude);
|
|
309
|
+
const inCone = coneOutcome === 'inside';
|
|
310
|
+
if (!Number.isFinite(distanceKm))
|
|
311
|
+
return null;
|
|
312
|
+
if (distanceKm <= TROPICAL_CONTEXT_RADIUS_KM || inCone)
|
|
313
|
+
return { distanceKm, inCone };
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
/** Nearest centre first; ties by storm id (ascending). Returns a new array. */
|
|
317
|
+
export function orderTropicalCycloneHits(items) {
|
|
318
|
+
return [...items].sort((a, b) => {
|
|
319
|
+
if (a.hit.distanceKm !== b.hit.distanceKm)
|
|
320
|
+
return a.hit.distanceKm - b.hit.distanceKm;
|
|
321
|
+
return a.storm.id < b.storm.id ? -1 : a.storm.id > b.storm.id ? 1 : 0;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
/** An ISO 8601 instant that names its zone (`Z` or an offset); a naive wall clock is refused (G162). */
|
|
325
|
+
const ISO_WITH_ZONE_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/;
|
|
326
|
+
function parseZonedInstant(value) {
|
|
327
|
+
if (value === undefined || !ISO_WITH_ZONE_RE.test(value))
|
|
328
|
+
return undefined;
|
|
329
|
+
const ms = Date.parse(value);
|
|
330
|
+
return Number.isFinite(ms) ? ms : undefined;
|
|
331
|
+
}
|
|
332
|
+
/** Whether the record's `lastUpdate` is parseable (with a zone) and at most 24 h before `nowMs`. */
|
|
333
|
+
export function isFresh(storm, nowMs) {
|
|
334
|
+
const updated = parseZonedInstant(storm.lastUpdate);
|
|
335
|
+
if (updated === undefined || !Number.isFinite(nowMs))
|
|
336
|
+
return false;
|
|
337
|
+
return nowMs - updated <= NHC_MAX_RECORD_AGE_MS;
|
|
338
|
+
}
|
|
339
|
+
const CLASSIFICATION_LABELS = Object.assign(Object.create(null), {
|
|
340
|
+
TD: 'Tropical Depression',
|
|
341
|
+
STD: 'Subtropical Depression',
|
|
342
|
+
TS: 'Tropical Storm',
|
|
343
|
+
STS: 'Subtropical Storm',
|
|
344
|
+
HU: 'Hurricane',
|
|
345
|
+
PTC: 'Post-Tropical Cyclone',
|
|
346
|
+
PC: 'Potential Tropical Cyclone'
|
|
347
|
+
});
|
|
348
|
+
const CLASSIFICATION_CODE_RE = /^[A-Z]{2,3}$/;
|
|
349
|
+
const STORM_NAME_RE = /^[A-Za-z][A-Za-z' -]{0,39}$/;
|
|
350
|
+
const STORM_ID_RE = /^[A-Za-z0-9]{1,12}$/;
|
|
351
|
+
const ADVISORY_NUMBER_RE = /^\d{1,3}[A-Za-z]?$/;
|
|
352
|
+
const KT_TO_MPH = 1.15078;
|
|
353
|
+
const KT_TO_KMH = 1.852;
|
|
354
|
+
const MPH_TO_KMH = 1.609344;
|
|
355
|
+
function positive(value) {
|
|
356
|
+
return value !== undefined && Number.isFinite(value) && value > 0;
|
|
357
|
+
}
|
|
358
|
+
function labelAndCode(classification) {
|
|
359
|
+
if (classification === undefined || !CLASSIFICATION_CODE_RE.test(classification)) {
|
|
360
|
+
return { label: 'Tropical cyclone' };
|
|
361
|
+
}
|
|
362
|
+
if (Object.prototype.hasOwnProperty.call(CLASSIFICATION_LABELS, classification)) {
|
|
363
|
+
return { label: CLASSIFICATION_LABELS[classification], code: classification };
|
|
364
|
+
}
|
|
365
|
+
return { label: 'Tropical cyclone', code: classification };
|
|
366
|
+
}
|
|
367
|
+
function displayName(storm) {
|
|
368
|
+
if (storm.name !== undefined && STORM_NAME_RE.test(storm.name))
|
|
369
|
+
return storm.name;
|
|
370
|
+
return STORM_ID_RE.test(storm.id) ? storm.id.toUpperCase() : undefined;
|
|
371
|
+
}
|
|
372
|
+
function normaliseSpaces(text) {
|
|
373
|
+
return text.replace(/[\u202F\u00A0]/g, ' ');
|
|
374
|
+
}
|
|
375
|
+
function movementClause(storm) {
|
|
376
|
+
const speed = storm.movementSpeedMph;
|
|
377
|
+
if (speed === undefined || !Number.isFinite(speed) || speed < 0)
|
|
378
|
+
return undefined;
|
|
379
|
+
const mph = Math.round(speed);
|
|
380
|
+
if (mph === 0)
|
|
381
|
+
return 'nearly stationary';
|
|
382
|
+
const speedText = `${mph} mph (${Math.round(speed * MPH_TO_KMH)} km/h)`;
|
|
383
|
+
const dir = storm.movementDir;
|
|
384
|
+
if (dir === undefined || !Number.isFinite(dir))
|
|
385
|
+
return `moving at ${speedText}`;
|
|
386
|
+
return `moving ${compassPoint(((dir % 360) + 360) % 360)} at ${speedText}`;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* One rendered line, ending in a newline. Each clause whose inputs are absent
|
|
390
|
+
* is dropped whole. Nothing here says a storm is absent, outside, or that
|
|
391
|
+
* nothing was found; the cone sentence renders only when `hit.inCone` is true.
|
|
392
|
+
* No Saffir-Simpson category is computed (NHC's own text names it).
|
|
393
|
+
*
|
|
394
|
+
* @param zone IANA zone of the point (`guessTimezoneFromCoords`), for the issue time.
|
|
395
|
+
*/
|
|
396
|
+
export function formatTropicalCycloneLine(storm, hit, zone, timeFormat, latitude, longitude) {
|
|
397
|
+
const { label, code } = labelAndCode(storm.classification);
|
|
398
|
+
const name = displayName(storm);
|
|
399
|
+
const head = [label, name].filter((part) => part !== undefined).join(' ') +
|
|
400
|
+
(code !== undefined ? ` (${code})` : '');
|
|
401
|
+
const segments = [head];
|
|
402
|
+
const strength = [];
|
|
403
|
+
if (positive(storm.intensityKt)) {
|
|
404
|
+
const kt = storm.intensityKt;
|
|
405
|
+
strength.push(`${Math.round(kt)} kt (${Math.round(kt * KT_TO_MPH)} mph, ${Math.round(kt * KT_TO_KMH)} km/h)`);
|
|
406
|
+
}
|
|
407
|
+
if (positive(storm.pressureMb))
|
|
408
|
+
strength.push(`${Math.round(storm.pressureMb)} mb`);
|
|
409
|
+
if (strength.length > 0)
|
|
410
|
+
segments.push(strength.join(', '));
|
|
411
|
+
const km = Math.round(hit.distanceKm);
|
|
412
|
+
let position;
|
|
413
|
+
if (km < 1) {
|
|
414
|
+
position = 'at this point';
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
const compass = compassPoint(bearingDegrees(latitude, longitude, storm.latitude, storm.longitude));
|
|
418
|
+
position = `${km} km (${Math.round(kmToMiles(hit.distanceKm))} mi) ${compass} of this point`;
|
|
419
|
+
}
|
|
420
|
+
const movement = movementClause(storm);
|
|
421
|
+
segments.push(movement === undefined ? position : `${position}, ${movement}`);
|
|
422
|
+
let text = `🌀 **Tropical cyclone:** ${segments.join(' — ')}.`;
|
|
423
|
+
if (hit.inCone)
|
|
424
|
+
text += ' This point is inside its 5-day forecast cone.';
|
|
425
|
+
const advisory = storm.advisoryNumber !== undefined && ADVISORY_NUMBER_RE.test(storm.advisoryNumber)
|
|
426
|
+
? storm.advisoryNumber
|
|
427
|
+
: undefined;
|
|
428
|
+
const issued = parseZonedInstant(storm.advisoryIssued) !== undefined
|
|
429
|
+
? normaliseSpaces(formatInTimezoneWithZone(storm.advisoryIssued, zone, 'medium', timeFormat))
|
|
430
|
+
: undefined;
|
|
431
|
+
if (advisory !== undefined && issued !== undefined)
|
|
432
|
+
text += ` NHC advisory ${advisory}, issued ${issued}.`;
|
|
433
|
+
else if (advisory !== undefined)
|
|
434
|
+
text += ` NHC advisory ${advisory}.`;
|
|
435
|
+
else if (issued !== undefined)
|
|
436
|
+
text += ` NHC advisory issued ${issued}.`;
|
|
437
|
+
return `${text}\n`;
|
|
438
|
+
}
|
|
439
|
+
//# sourceMappingURL=tropicalCyclones.js.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AAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,KAAK,QAAQ,EAAE,CAAC,CAAC;IAE9E,IAAI,IAAI,GAAG,4BAA4B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;IAC/D,IAAI,GAAG,CAAC,MAAM;QAAE,IAAI,IAAI,gDAAgD,CAAC;IAEzE,MAAM,QAAQ,GACZ,KAAK,CAAC,cAAc,KAAK,SAAS,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QACjF,CAAC,CAAC,KAAK,CAAC,cAAc;QACtB,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,MAAM,GACV,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,SAAS;QACnD,CAAC,CAAC,eAAe,CAAC,wBAAwB,CAAC,KAAK,CAAC,cAAwB,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACvG,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;QAAE,IAAI,IAAI,iBAAiB,QAAQ,YAAY,MAAM,GAAG,CAAC;SACtG,IAAI,QAAQ,KAAK,SAAS;QAAE,IAAI,IAAI,iBAAiB,QAAQ,GAAG,CAAC;SACjE,IAAI,MAAM,KAAK,SAAS;QAAE,IAAI,IAAI,wBAAwB,MAAM,GAAG,CAAC;IAEzE,OAAO,GAAG,IAAI,IAAI,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dangahagan/weather-mcp",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.2",
|
|
4
4
|
"description": "MCP server giving AI assistants 18 weather tools with zero API keys: global forecasts, current conditions, alerts, air quality, marine conditions, lightning detection, radar imagery, river levels, wildfire tracking, and historical weather back to 1940. Built entirely on free public data sources (NOAA, Open-Meteo, USGS, NIFC).",
|
|
5
5
|
"mcpName": "io.github.dgahagan/weather-mcp",
|
|
6
6
|
"main": "dist/index.js",
|