feat: Add support for decoding obscuration remarks like FG8
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+18
@@ -208,12 +208,30 @@
|
|||||||
return `${code}: ${decodedParts.join(', ')}`;
|
return `${code}: ${decodedParts.join(', ')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decodeObscurationRemark(code) {
|
||||||
|
const weatherMap = {
|
||||||
|
'FG': 'Fog',
|
||||||
|
'BR': 'Mist',
|
||||||
|
'FU': 'Smoke',
|
||||||
|
'HZ': 'Haze',
|
||||||
|
'DU': 'Widespread dust',
|
||||||
|
'SA': 'Sand',
|
||||||
|
};
|
||||||
|
const weatherCode = code.substring(0, 2);
|
||||||
|
const oktas = code.substring(2);
|
||||||
|
const weatherName = weatherMap[weatherCode];
|
||||||
|
return `${code}: ${weatherName} obscuring ${oktas}/8 of the sky`;
|
||||||
|
}
|
||||||
|
|
||||||
function decodeRemarks(parts) {
|
function decodeRemarks(parts) {
|
||||||
let decoded = ["RMK: Remarks"];
|
let decoded = ["RMK: Remarks"];
|
||||||
const weatherRegex = /^([+-]|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)+$/;
|
const weatherRegex = /^([+-]|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)+$/;
|
||||||
|
const obscurationRegex = /^(FG|BR|FU|HZ|DU|SA)\d$/;
|
||||||
parts.forEach(part => {
|
parts.forEach(part => {
|
||||||
if (part.startsWith('SLP')) {
|
if (part.startsWith('SLP')) {
|
||||||
decoded.push(` - ${decodeSlp(part)}`);
|
decoded.push(` - ${decodeSlp(part)}`);
|
||||||
|
} else if (obscurationRegex.test(part)) {
|
||||||
|
decoded.push(` - ${decodeObscurationRemark(part)}`);
|
||||||
} else if (part.match(/^([A-Z]{2}\d)+$/)) {
|
} else if (part.match(/^([A-Z]{2}\d)+$/)) {
|
||||||
decoded.push(` - ${decodeCloudTypesRemark(part)}`);
|
decoded.push(` - ${decodeCloudTypesRemark(part)}`);
|
||||||
} else if (weatherRegex.test(part)) {
|
} else if (weatherRegex.test(part)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user