feat: Add support for advanced VIS LW remark decoding
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+48
-7
@@ -492,10 +492,37 @@
|
||||
},
|
||||
// VIS
|
||||
{
|
||||
match: p => p[0] === 'VIS' && p.length > 2 && (isDirection(p[1]) || (p[1] === 'LW' && p.length > 3 && isDirection(p[3]))),
|
||||
match: p => p[0] === 'VIS' && p.length > 2 && (isDirection(p[1]) || (p[1] === 'LW' && p.length > 3 && (isDirection(p[2]) || isDirection(p[3])))),
|
||||
decode: p => {
|
||||
// VIS LW <visibility> <direction>
|
||||
// VIS LW ...
|
||||
if (p[1] === 'LW') {
|
||||
// VIS LW <direction> <visibility>... (new format)
|
||||
if (isDirection(p[2])) {
|
||||
const direction = p[2];
|
||||
let vis_parts = [p[3]];
|
||||
let vis_consumed = 1;
|
||||
|
||||
if (p.length > 4) {
|
||||
if (p[4] === 'SM') { // "3 SM"
|
||||
vis_parts.push(p[4]);
|
||||
vis_consumed++;
|
||||
} else if (p[3].match(/^\d+$/) && p[4].match(/^\d+\/\d+SM$/)) { // "1 1/2SM"
|
||||
vis_parts.push(p[4]);
|
||||
vis_consumed++;
|
||||
}
|
||||
}
|
||||
const raw_vis = vis_parts.join(' ');
|
||||
const raw_remark = ['VIS', 'LW', direction, raw_vis].join(' ');
|
||||
const visibility = raw_vis.replace('SM', '');
|
||||
|
||||
return {
|
||||
consumed: 3 + vis_consumed,
|
||||
text: ` - ${raw_remark}: Visibility locally worse, ${visibility} statute miles to the ${decodeDirection(direction).replace(/ to /g, '-')}`
|
||||
};
|
||||
}
|
||||
|
||||
// VIS LW <visibility> <direction> (old format)
|
||||
if (isDirection(p[3])) {
|
||||
const visibility = p[2].replace('SM', '');
|
||||
const direction = p[3];
|
||||
return {
|
||||
@@ -503,20 +530,34 @@
|
||||
text: ` - VIS LW ${p[2]} ${direction}: Visibility locally worse, ${visibility} statute miles to the ${decodeDirection(direction).replace(/ to /g, '-')}`
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// VIS <direction> <visibility>
|
||||
if (isDirection(p[1])) {
|
||||
const visibility = p[2].replace('SM', '');
|
||||
const direction = p[1];
|
||||
const raw_vis = p[2];
|
||||
let consumed = 3;
|
||||
let vis_parts = [p[2]];
|
||||
let vis_consumed = 1;
|
||||
|
||||
if (p.length > 3) {
|
||||
if (p[3] === 'SM') { // "3 SM"
|
||||
vis_parts.push(p[3]);
|
||||
vis_consumed++;
|
||||
} else if (p[2].match(/^\d+$/) && p[3].match(/^\d+\/\d+SM$/)) { // "1 1/2SM"
|
||||
vis_parts.push(p[3]);
|
||||
vis_consumed++;
|
||||
}
|
||||
}
|
||||
const raw_vis = vis_parts.join(' ');
|
||||
const visibility = raw_vis.replace('SM', '');
|
||||
|
||||
let consumed = 2 + vis_consumed;
|
||||
let raw_parts = ['VIS', direction, raw_vis];
|
||||
let text_parts = [];
|
||||
|
||||
text_parts.push(`Visibility ${decodeDirection(direction)} ${visibility} miles`);
|
||||
|
||||
if (p.length > 3 && p[3] === 'INTMT') {
|
||||
consumed = 4;
|
||||
if (p.length > (2 + vis_consumed) && p[2 + vis_consumed] === 'INTMT') {
|
||||
consumed++;
|
||||
raw_parts.push('INTMT');
|
||||
text_parts.push('intermittent');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user