fix: Correct CYVR typo, improve visibility parsing, and handle unknown components
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+15
-4
@@ -64,7 +64,7 @@
|
|||||||
if (code === 'CYYC') return "CYYC: Calgary International Airport";
|
if (code === 'CYYC') return "CYYC: Calgary International Airport";
|
||||||
if (code === 'CYEG') return "CYEG: Edmonton International Airport";
|
if (code === 'CYEG') return "CYEG: Edmonton International Airport";
|
||||||
if (code === 'CYXS') return "CYXS: Prince George Airport";
|
if (code === 'CYXS') return "CYXS: Prince George Airport";
|
||||||
if (code === 'CYVR') return "CVYR: Vancouver International Airport";
|
if (code === 'CYVR') return "CYVR: Vancouver International Airport";
|
||||||
if (code === 'CYBW') return "CYBW: Calgary/Springbank Airport";
|
if (code === 'CYBW') return "CYBW: Calgary/Springbank Airport";
|
||||||
console.log(`Unknown Airport code: ${code} in METAR: ${metarString}`);
|
console.log(`Unknown Airport code: ${code} in METAR: ${metarString}`);
|
||||||
return `${code}: Unknown Airport`;
|
return `${code}: Unknown Airport`;
|
||||||
@@ -559,10 +559,18 @@
|
|||||||
const mainParts = rmkIndex !== -1 ? parts.slice(index, rmkIndex) : parts.slice(index);
|
const mainParts = rmkIndex !== -1 ? parts.slice(index, rmkIndex) : parts.slice(index);
|
||||||
|
|
||||||
// Intermediate sections
|
// Intermediate sections
|
||||||
mainParts.forEach(part => {
|
for (let i = 0; i < mainParts.length; i++) {
|
||||||
|
let part = mainParts[i];
|
||||||
|
|
||||||
|
// Check for mixed fraction visibility, e.g., "1 1/2SM" which is split into "1" and "1/2SM"
|
||||||
|
if (part.match(/^\d+$/) && (i + 1) < mainParts.length && mainParts[i+1].match(/^\d\/\dSM$/)) {
|
||||||
|
part = `${part} ${mainParts[i+1]}`;
|
||||||
|
i++; // Consume next part
|
||||||
|
}
|
||||||
|
|
||||||
if (part.endsWith('KT')) {
|
if (part.endsWith('KT')) {
|
||||||
sections.push({ raw: part, decoded: decodeWind(part) });
|
sections.push({ raw: part, decoded: decodeWind(part) });
|
||||||
} else if (part.endsWith('SM') || part.match(/^\d+$/) || part.match(/^\d\/\dSM$/)) {
|
} else if (part.endsWith('SM') || part.match(/^\d+$/)) {
|
||||||
sections.push({ raw: part, decoded: decodeVisibility(part) });
|
sections.push({ raw: part, decoded: decodeVisibility(part) });
|
||||||
} else if (part.match(/^([+-]|VC)?(MI|PR|BC|DR|BL|SH|TS|FZ|DZ|RA|SN|SG|IC|PL|GR|GS|UP|BR|FG|FU|VA|DU|SA|HZ|PY|PO|SQ|FC|SS|DS|TR)+$/)) {
|
} else if (part.match(/^([+-]|VC)?(MI|PR|BC|DR|BL|SH|TS|FZ|DZ|RA|SN|SG|IC|PL|GR|GS|UP|BR|FG|FU|VA|DU|SA|HZ|PY|PO|SQ|FC|SS|DS|TR)+$/)) {
|
||||||
sections.push({ raw: part, decoded: decodeWeather(part, metarString) });
|
sections.push({ raw: part, decoded: decodeWeather(part, metarString) });
|
||||||
@@ -572,8 +580,11 @@
|
|||||||
sections.push({ raw: part, decoded: decodeTempDew(part) });
|
sections.push({ raw: part, decoded: decodeTempDew(part) });
|
||||||
} else if (part.startsWith('A') && part.length === 5 && !isNaN(part.substring(1))) {
|
} else if (part.startsWith('A') && part.length === 5 && !isNaN(part.substring(1))) {
|
||||||
sections.push({ raw: part, decoded: decodeAltimeter(part) });
|
sections.push({ raw: part, decoded: decodeAltimeter(part) });
|
||||||
|
} else {
|
||||||
|
console.log(`Unknown main METAR part: ${part} in METAR: ${metarString}`);
|
||||||
|
sections.push({ raw: part, decoded: `${part}: Unknown METAR component` });
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Remarks section
|
// Remarks section
|
||||||
if (rmkIndex !== -1) {
|
if (rmkIndex !== -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user