feat: Add decoding for METAR correction codes and refactor preamble parsing

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-14 18:01:32 -07:00
parent 78a1bb6e42
commit ff9f9de982
+23 -14
View File
@@ -737,22 +737,31 @@
// Section 1: Airport, Time, Auto // Section 1: Airport, Time, Auto
let airportTimeAutoRaw = []; let airportTimeAutoRaw = [];
let airportTimeAutoDecoded = []; let airportTimeAutoDecoded = [];
let preambleEnded = false;
if (parts[index] && parts[index].length === 4 && parts[index].match(/^[A-Z][A-Z0-9]{3}$/)) { while(index < parts.length && !preambleEnded) {
airportTimeAutoRaw.push(parts[index]); const part = parts[index];
airportTimeAutoDecoded.push(decodeAirport(parts[index], metarString)); if (part.length === 4 && part.match(/^[A-Z][A-Z0-9]{3}$/)) {
index++; airportTimeAutoRaw.push(part);
} airportTimeAutoDecoded.push(decodeAirport(part, metarString));
if (parts[index] && parts[index].endsWith('Z')) { index++;
airportTimeAutoRaw.push(parts[index]); } else if (part.endsWith('Z')) {
airportTimeAutoDecoded.push(decodeTime(parts[index])); airportTimeAutoRaw.push(part);
index++; airportTimeAutoDecoded.push(decodeTime(part));
} index++;
if (parts[index] && parts[index] === 'AUTO') { } else if (part === 'AUTO') {
airportTimeAutoRaw.push(parts[index]); airportTimeAutoRaw.push(part);
airportTimeAutoDecoded.push("AUTO: Fully automated observation"); airportTimeAutoDecoded.push("AUTO: Fully automated observation");
index++; index++;
} else if (part.match(/^CC[A-Z]$/)) {
airportTimeAutoRaw.push(part);
airportTimeAutoDecoded.push(`${part}: Correction to the report`);
index++;
} else {
preambleEnded = true;
}
} }
if (airportTimeAutoRaw.length > 0) { if (airportTimeAutoRaw.length > 0) {
sections.push({ sections.push({
raw: airportTimeAutoRaw.join(' '), raw: airportTimeAutoRaw.join(' '),