refactor: Decode multi-word cloud remarks like "SC TR"
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+20
-2
@@ -234,13 +234,31 @@
|
||||
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 obscurationRegex = /^(FG|BR|FU|HZ|DU|SA)\d$/;
|
||||
parts.forEach(part => {
|
||||
const cloudTypes = {
|
||||
'CI': 'Cirrus',
|
||||
'CC': 'Cirrocumulus',
|
||||
'CS': 'Cirrostratus',
|
||||
'AC': 'Altocumulus',
|
||||
'AS': 'Altostratus',
|
||||
'NS': 'Nimbostratus',
|
||||
'SC': 'Stratocumulus',
|
||||
'ST': 'Stratus',
|
||||
'CU': 'Cumulus',
|
||||
'CB': 'Cumulonimbus'
|
||||
};
|
||||
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const part = parts[i];
|
||||
if (part.startsWith('SLP')) {
|
||||
decoded.push(` - ${decodeSlp(part)}`);
|
||||
} else if (obscurationRegex.test(part)) {
|
||||
decoded.push(` - ${decodeObscurationRemark(part)}`);
|
||||
} else if (part.match(/^([A-Z]{2}\d)+$/)) {
|
||||
decoded.push(` - ${decodeCloudTypesRemark(part)}`);
|
||||
} else if (cloudTypes[part] && i + 1 < parts.length && parts[i + 1] === 'TR') {
|
||||
const cloudName = cloudTypes[part];
|
||||
decoded.push(` - ${part} ${parts[i+1]}: ${cloudName} clouds are translucent (thin)`);
|
||||
i++; // Consume 'TR' part
|
||||
} else if (weatherRegex.test(part)) {
|
||||
decoded.push(` - ${decodeWeather(part)}`);
|
||||
} else if (part.match(/^(AC|CI|CC)/)) {
|
||||
@@ -248,7 +266,7 @@
|
||||
} else {
|
||||
decoded.push(` - ${part}: Other remark`);
|
||||
}
|
||||
});
|
||||
}
|
||||
return decoded.join('\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user