mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
Merge PR #1389 contribution for review
This commit is contained in:
commit
1244ec1332
3 files changed
+16
-1
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
- Show cockpit wind from 359.5° or more as 0°, not 360°. Rounding 359.6°
|
||||||
|
printed "N · 360°" on the local wind direction
|
||||||
|
(Rudy Celekli, @rudycelekli, #1389).
|
||||||
@@ -156,7 +156,9 @@ export function formatCockpitWindDirection(value) {
|
|||||||
if (!Number.isFinite(value)) return t('DIR UNKNOWN');
|
if (!Number.isFinite(value)) return t('DIR UNKNOWN');
|
||||||
const labels = Object.keys(COMPASS_POINT_LABELS);
|
const labels = Object.keys(COMPASS_POINT_LABELS);
|
||||||
const normalized = ((value % 360) + 360) % 360;
|
const normalized = ((value % 360) + 360) % 360;
|
||||||
return `${compassPointLabel(labels[Math.round(normalized / 45) % labels.length])} · ${Math.round(normalized)}°`;
|
// 359.5° and above is north. Modulo keeps that from printing 360°.
|
||||||
|
const degrees = Math.round(normalized) % 360;
|
||||||
|
return `${compassPointLabel(labels[Math.round(normalized / 45) % labels.length])} · ${degrees}°`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Digit grouping and decimal marks (`26,175`, `26 175`, `26.175`) take a
|
// Digit grouping and decimal marks (`26,175`, `26 175`, `26.175`) take a
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { formatCockpitWindDirection } from './cockpitPresentation.js';
|
||||||
|
|
||||||
|
test('wind just west of north reads 0°, not 360°', () => {
|
||||||
|
assert.equal(formatCockpitWindDirection(90), 'E · 90°');
|
||||||
|
assert.equal(formatCockpitWindDirection(0), 'N · 0°');
|
||||||
|
assert.equal(formatCockpitWindDirection(359.4), 'N · 359°');
|
||||||
|
assert.equal(formatCockpitWindDirection(359.6), 'N · 0°');
|
||||||
|
});
|
||||||
Reference in new issue
Block a user