Skip to content

Commit

Permalink
Added support for 3 digits in gusts for Wind and Windshear elements
Browse files Browse the repository at this point in the history
  • Loading branch information
mivek committed Aug 20, 2023
1 parent 1b23ea8 commit a357c06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public final class WindCommand implements BaseWindCommand {
/** Pattern regex for wind. */
private static final Pattern WIND_REGEX = Pattern.compile("^(VRB|00|[0-3]\\d{2})(\\d{2})G?(\\d{2})?(KT|MPS|KM/H)?");
private static final Pattern WIND_REGEX = Pattern.compile("^(VRB|00|[0-3]\\d{2})(\\d{2})G?(\\d{2,3})?(KT|MPS|KM/H)?");

/**
* Package private constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public final class WindShearCommand implements BaseWindCommand {
/** Pattern regex for windshear. */
private static final Pattern WIND_SHEAR_REGEX = Pattern.compile("^WS(\\d{3})/(\\w{3})(\\d{2})G?(\\d{2})?(KT|MPS|KM/H)");
private static final Pattern WIND_SHEAR_REGEX = Pattern.compile("^WS(\\d{3})/(\\w{3})(\\d{2})G?(\\d{2,3})?(KT|MPS|KM/H)");

/**
* Package private constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ void testExecuteWithExistingWind() {
assertTrue(command.execute(m, "VRB08KT"));
assertEquals(wind1, m.getWind());
}

@Test
void testParseWindThreeDigitGust() {
Wind w = command.parseWind("12017G015KT");
assertEquals(Messages.getInstance().getString("Converter.ESE"), w.getDirection());
assertEquals(120, w.getDirectionDegrees());
assertEquals(17, w.getSpeed());
assertEquals(15, w.getGust());
assertEquals("KT", w.getUnit());
}
}

0 comments on commit a357c06

Please sign in to comment.