File tree Expand file tree Collapse file tree 2 files changed +33
-6
lines changed
Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import { ICommand } from "../metar";
1313export class RunwayCommand implements ICommand {
1414 #genericRegex = / ^ ( R \d { 2 } \w ? \/ ) / ;
1515 #runwayMaxRangeRegex =
16- / ^ R ( \d { 2 } \w ? ) \/ ( \d { 4 } ) V ( \d { 3 , 4 } ) (?: ( [ U D N ] ) | ( F T ) (?: \/ ( [ U D N ] ) ) ? ) $ / ;
16+ / ^ R ( \d { 2 } \w ? ) \/ ( \d { 4 } ) V ( [ M P ] ) ? ( \d { 3 , 4 } ) (?: ( [ U D N ] ) | ( F T ) (?: \/ ( [ U D N ] ) ) ? ) $ / ;
1717 #runwayRegex = / ^ R ( \d { 2 } \w ? ) \/ ( [ M P ] ) ? ( \d { 4 } ) (?: ( [ U D N ] ) | ( F T ) (?: \/ ( [ U D N ] ) ) ? ) $ / ;
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 } ) ;
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments