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:
+54
-13
@@ -492,31 +492,72 @@
|
|||||||
},
|
},
|
||||||
// VIS
|
// 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 => {
|
decode: p => {
|
||||||
// VIS LW <visibility> <direction>
|
// VIS LW ...
|
||||||
if (p[1] === 'LW') {
|
if (p[1] === 'LW') {
|
||||||
const visibility = p[2].replace('SM', '');
|
// VIS LW <direction> <visibility>... (new format)
|
||||||
const direction = p[3];
|
if (isDirection(p[2])) {
|
||||||
return {
|
const direction = p[2];
|
||||||
consumed: 4,
|
let vis_parts = [p[3]];
|
||||||
text: ` - VIS LW ${p[2]} ${direction}: Visibility locally worse, ${visibility} statute miles to the ${decodeDirection(direction).replace(/ to /g, '-')}`
|
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 {
|
||||||
|
consumed: 4,
|
||||||
|
text: ` - VIS LW ${p[2]} ${direction}: Visibility locally worse, ${visibility} statute miles to the ${decodeDirection(direction).replace(/ to /g, '-')}`
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VIS <direction> <visibility>
|
// VIS <direction> <visibility>
|
||||||
if (isDirection(p[1])) {
|
if (isDirection(p[1])) {
|
||||||
const visibility = p[2].replace('SM', '');
|
|
||||||
const direction = p[1];
|
const direction = p[1];
|
||||||
const raw_vis = p[2];
|
let vis_parts = [p[2]];
|
||||||
let consumed = 3;
|
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 raw_parts = ['VIS', direction, raw_vis];
|
||||||
let text_parts = [];
|
let text_parts = [];
|
||||||
|
|
||||||
text_parts.push(`Visibility ${decodeDirection(direction)} ${visibility} miles`);
|
text_parts.push(`Visibility ${decodeDirection(direction)} ${visibility} miles`);
|
||||||
|
|
||||||
if (p.length > 3 && p[3] === 'INTMT') {
|
if (p.length > (2 + vis_consumed) && p[2 + vis_consumed] === 'INTMT') {
|
||||||
consumed = 4;
|
consumed++;
|
||||||
raw_parts.push('INTMT');
|
raw_parts.push('INTMT');
|
||||||
text_parts.push('intermittent');
|
text_parts.push('intermittent');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user