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