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:
+19
-10
@@ -737,22 +737,31 @@
|
||||
// Section 1: Airport, Time, Auto
|
||||
let airportTimeAutoRaw = [];
|
||||
let airportTimeAutoDecoded = [];
|
||||
let preambleEnded = false;
|
||||
|
||||
if (parts[index] && parts[index].length === 4 && parts[index].match(/^[A-Z][A-Z0-9]{3}$/)) {
|
||||
airportTimeAutoRaw.push(parts[index]);
|
||||
airportTimeAutoDecoded.push(decodeAirport(parts[index], metarString));
|
||||
while(index < parts.length && !preambleEnded) {
|
||||
const part = parts[index];
|
||||
if (part.length === 4 && part.match(/^[A-Z][A-Z0-9]{3}$/)) {
|
||||
airportTimeAutoRaw.push(part);
|
||||
airportTimeAutoDecoded.push(decodeAirport(part, metarString));
|
||||
index++;
|
||||
}
|
||||
if (parts[index] && parts[index].endsWith('Z')) {
|
||||
airportTimeAutoRaw.push(parts[index]);
|
||||
airportTimeAutoDecoded.push(decodeTime(parts[index]));
|
||||
} else if (part.endsWith('Z')) {
|
||||
airportTimeAutoRaw.push(part);
|
||||
airportTimeAutoDecoded.push(decodeTime(part));
|
||||
index++;
|
||||
}
|
||||
if (parts[index] && parts[index] === 'AUTO') {
|
||||
airportTimeAutoRaw.push(parts[index]);
|
||||
} else if (part === 'AUTO') {
|
||||
airportTimeAutoRaw.push(part);
|
||||
airportTimeAutoDecoded.push("AUTO: Fully automated observation");
|
||||
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) {
|
||||
sections.push({
|
||||
raw: airportTimeAutoRaw.join(' '),
|
||||
|
||||
Reference in New Issue
Block a user