fix wind calculation/display
This commit is contained in:
@@ -53,7 +53,7 @@ const LimitsMatrix = ({ metar }) => {
|
||||
},
|
||||
{
|
||||
label: 'Crosswind',
|
||||
value: `${metar.crosswind}kts (R${metar.runway})`,
|
||||
value: `${metar.crosswind ?? 0}kts ${metar.runway ? `(R${metar.runway})` : ''}`,
|
||||
pattern: withinLimits('pattern', 'crosswind', metar.crosswind),
|
||||
dual: withinLimits('dual', 'crosswind', metar.crosswind),
|
||||
solo: withinLimits('solo', 'crosswind', metar.crosswind),
|
||||
|
||||
@@ -24,20 +24,15 @@ export function decodeMetar(metar) {
|
||||
const baseWind = parseInt(windMatch[2], 10);
|
||||
const gust = windMatch[4] ? parseInt(windMatch[4], 10) : null;
|
||||
|
||||
result.direction =
|
||||
dir === 'VRB'
|
||||
? 'variable'
|
||||
: dir === '000' && baseWind === 0
|
||||
? 'calm'
|
||||
: parseInt(dir, 10);
|
||||
result.direction = dir === 'VRB' ? 'variable' : parseInt(dir, 10);
|
||||
|
||||
result.gusts = gust;
|
||||
const effectiveWind = gust ? Math.max(baseWind, gust) : baseWind;
|
||||
result.wind = effectiveWind;
|
||||
|
||||
// Runway calculations
|
||||
if (typeof result.direction === 'number') {
|
||||
const windDir = result.direction;
|
||||
if (true) {
|
||||
const windDir = result.direction || 0;
|
||||
|
||||
result.runwayBreakdown = runways.map(({ id, heading }) => {
|
||||
const angleDiff = Math.abs(windDir - heading);
|
||||
@@ -60,8 +55,9 @@ export function decodeMetar(metar) {
|
||||
a.headwind > b.headwind ? a : b,
|
||||
);
|
||||
|
||||
result.runway = best.runway;
|
||||
result.runway = dir === '000' && baseWind === 0 ? null : best.runway;
|
||||
result.crosswind = Math.abs(best.crosswind);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user