A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
fix(cyclones): convert NHC movement speed from mph to knots
Rudy Celekli0b19f11ad0d2
diff --git a/server/providers/cyclones.js b/server/providers/cyclones.jsindex 3e5f2f6d1..5aab0f246 100644--- a/server/providers/cyclones.js+++ b/server/providers/cyclones.js@@ -43,6 +43,11 @@ function number(value, min, max) {const n = Number(value);return Number.isFinite(n) && n >= min && n <= max ? n : null;}+// CurrentStorms.json reports movementSpeed in miles per hour (intensity is in+// knots); convert so `speedKt` means what it says.+function knotsFromMph(mph) {+ return mph === null ? null : Math.round(mph * 0.868976);+}// NHC stamps an advisory with its nominal time (e.g. 03:00Z) and publishes it// up to about half an hour before; allow that, but not a clock far ahead.const EARLY_ADVISORY_MS = 90 * 60_000;@@ -120,7 +125,7 @@ export function parseCycloneStatus(payload, now = Date.now()) {pressureHpa: number(raw.pressure, 800, 1100),movement: {directionDegrees: number(raw.movementDir, 0, 360),- speedKt: number(raw.movementSpeed, 0, 200),+ speedKt: knotsFromMph(number(raw.movementSpeed, 0, 200)),},advisoryUrl: officialLink(forecast.url),outlookUrl: raw.id.startsWith('al')diff --git a/src/data/cyclonesProxy.test.mjs b/src/data/cyclonesProxy.test.mjsindex 23e84826c..6757f6e5c 100644--- a/src/data/cyclonesProxy.test.mjs+++ b/src/data/cyclonesProxy.test.mjs@@ -115,7 +115,8 @@ test('status retains official clocks, knots, source links and finite current posassert.equal(storm.issuedAt, TIME);assert.equal(storm.positionAt, TIME);assert.deepEqual(storm.position, { longitude: -125.8, latitude: 15.5 });- assert.deepEqual(storm.movement, { directionDegrees: 255, speedKt: 12 });+ // NHC publishes movementSpeed in mph: 12 mph is 10 kt.+ assert.deepEqual(storm.movement, { directionDegrees: 255, speedKt: 10 });assert.equal(storm.windKt, 25);assert.equal(storm.pressureHpa, 1006);assert.match(storm.advisoryUrl, /^https:\/\/www\.nhc\.noaa\.gov\/text\//);