Skip to content

Commit cf3d81e

Browse files
committed
Added support for a value indicator for rvr range reports (fixes #117)
1 parent 870a65f commit cf3d81e

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

src/command/metar/RunwayCommand.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ICommand } from "../metar";
1313
export class RunwayCommand implements ICommand {
1414
#genericRegex = /^(R\d{2}\w?\/)/;
1515
#runwayMaxRangeRegex =
16-
/^R(\d{2}\w?)\/(\d{4})V(\d{3,4})(?:([UDN])|(FT)(?:\/([UDN]))?)$/;
16+
/^R(\d{2}\w?)\/(\d{4})V([MP])?(\d{3,4})(?:([UDN])|(FT)(?:\/([UDN]))?)$/;
1717
#runwayRegex = /^R(\d{2}\w?)\/([MP])?(\d{4})(?:([UDN])|(FT)(?:\/([UDN]))?)$/;
1818
#runwayDepositRegex = /^R(\d{2}\w?)\/([/\d])([/\d])(\/\/|\d{2})(\/\/|\d{2})$/;
1919

@@ -64,18 +64,20 @@ export class RunwayCommand implements ICommand {
6464

6565
if (!matches) throw new UnexpectedParseError("Should be able to parse");
6666

67+
const indicator = matches[3] ? as(matches[3], ValueIndicator) : undefined;
6768
const trend = (() => {
68-
if (matches[6]) return as(matches[6], RunwayInfoTrend);
69-
if (matches[4]) return as(matches[4], RunwayInfoTrend);
69+
if (matches[7]) return as(matches[7], RunwayInfoTrend);
70+
if (matches[5]) return as(matches[5], RunwayInfoTrend);
7071
})();
71-
const unit = matches[5]
72-
? as(matches[5], RunwayInfoUnit)
72+
const unit = matches[6]
73+
? as(matches[6], RunwayInfoUnit)
7374
: RunwayInfoUnit.Meters;
7475

7576
metar.runwaysInfo.push({
7677
name: matches[1],
78+
indicator,
7779
minRange: +matches[2],
78-
maxRange: +matches[3],
80+
maxRange: +matches[4],
7981
trend,
8082
unit,
8183
});

tests/command/metar/RunwayCommand.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,31 @@ describe("RunwayCommand", () => {
122122
});
123123
})();
124124

125+
(() => {
126+
const code = "R08R/5000VP6000FT/D"; // runway info range north america style with indicator
127+
const metar = { runwaysInfo: [] } as unknown as IMetar;
128+
129+
describe(code, () => {
130+
test("canParse", () => {
131+
expect(command.canParse(code)).toBe(true);
132+
});
133+
134+
test("parse", () => {
135+
command.execute(metar, code);
136+
137+
expect(metar.runwaysInfo).toHaveLength(1);
138+
expect(metar.runwaysInfo[0]).toEqual({
139+
name: "08R",
140+
minRange: 5000,
141+
maxRange: 6000,
142+
indicator: ValueIndicator.GreaterThan,
143+
unit: RunwayInfoUnit.Feet,
144+
trend: RunwayInfoTrend.Decreasing,
145+
});
146+
});
147+
});
148+
})();
149+
125150
(() => {
126151
const code = "R01L/0800FT"; // runway info range feet simple
127152
const metar = { runwaysInfo: [] } as unknown as IMetar;

0 commit comments

Comments
 (0)