File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import { ICommand } from "../metar";
1212
1313export class RunwayCommand implements ICommand {
1414 #genericRegex = / ^ ( R \d { 2 } \w ? \/ ) / ;
15- #runwayMaxRangeRegex = / ^ R ( \d { 2 } \w ? ) \/ ( \d { 4 } ) V ( \d { 3 , 4 } ) ( [ U D N ] ) ? ( F T ) ? / ;
15+ #runwayMaxRangeRegex =
16+ / ^ R ( \d { 2 } \w ? ) \/ ( \d { 4 } ) V ( \d { 3 , 4 } ) (?: ( [ U D N ] ) | ( F T ) (?: \/ ( [ U D N ] ) ) ? ) $ / ;
1617 #runwayRegex = / ^ R ( \d { 2 } \w ? ) \/ ( [ M P ] ) ? ( \d { 4 } ) (?: ( [ U D N ] ) | ( F T ) (?: \/ ( [ U D N ] ) ) ? ) $ / ;
1718 #runwayDepositRegex = / ^ R ( \d { 2 } \w ? ) \/ ( [ / \d ] ) ( [ / \d ] ) ( \/ \/ | \d { 2 } ) ( \/ \/ | \d { 2 } ) $ / ;
1819
@@ -63,7 +64,10 @@ export class RunwayCommand implements ICommand {
6364
6465 if ( ! matches ) throw new UnexpectedParseError ( "Should be able to parse" ) ;
6566
66- const trend = matches [ 4 ] ? as ( matches [ 4 ] , RunwayInfoTrend ) : undefined ;
67+ const trend = ( ( ) => {
68+ if ( matches [ 6 ] ) return as ( matches [ 6 ] , RunwayInfoTrend ) ;
69+ if ( matches [ 4 ] ) return as ( matches [ 4 ] , RunwayInfoTrend ) ;
70+ } ) ( ) ;
6771 const unit = matches [ 5 ]
6872 ? as ( matches [ 5 ] , RunwayInfoUnit )
6973 : RunwayInfoUnit . Meters ;
Original file line number Diff line number Diff line change @@ -98,6 +98,30 @@ describe("RunwayCommand", () => {
9898 } ) ;
9999 } ) ( ) ;
100100
101+ ( ( ) => {
102+ const code = "R08L/1400V1800FT/N" ; // runway info range north america style
103+ const metar = { runwaysInfo : [ ] } as unknown as IMetar ;
104+
105+ describe ( code , ( ) => {
106+ test ( "canParse" , ( ) => {
107+ expect ( command . canParse ( code ) ) . toBe ( true ) ;
108+ } ) ;
109+
110+ test ( "parse" , ( ) => {
111+ command . execute ( metar , code ) ;
112+
113+ expect ( metar . runwaysInfo ) . toHaveLength ( 1 ) ;
114+ expect ( metar . runwaysInfo [ 0 ] ) . toEqual ( {
115+ name : "08L" ,
116+ minRange : 1400 ,
117+ maxRange : 1800 ,
118+ unit : RunwayInfoUnit . Feet ,
119+ trend : RunwayInfoTrend . NoSignificantChange ,
120+ } ) ;
121+ } ) ;
122+ } ) ;
123+ } ) ( ) ;
124+
101125 ( ( ) => {
102126 const code = "R01L/0800FT" ; // runway info range feet simple
103127 const metar = { runwaysInfo : [ ] } as unknown as IMetar ;
You can’t perform that action at this time.
0 commit comments