Skip to content

Commit a9f7c94

Browse files
authored
Merge pull request #783 from f-loris/improvement/runway-parsing
fix: improve runway parsing
2 parents 7219101 + 9856a56 commit a9f7c94

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ private String parseDepositThickness(final String input) {
164164
* @return Translated sentence representing the braking capacity.
165165
*/
166166
private String parseDepositBrakingCapacity(final String input) {
167+
if ("//".equals(input)) {
168+
return messages.getString(DEPOSIT_BRAKING_CAPACITY_MAP.get(input));
169+
}
167170
return messages.getString(DEPOSIT_BRAKING_CAPACITY_MAP.getOrDefault(input, "DepositBrakingCapacity.default"), Double.parseDouble(input) / 100);
168171
}
169172
@Override
170173
public boolean canParse(final String input) {
171174
return Regex.find(GENERIC_RUNWAY_REGEX, input);
172175
}
173176
}
174-

metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,26 @@ void testParseRunwayWithGreaterThanIndicator() throws ParseException {
156156
}
157157

158158
@Test
159-
void testParseRunwayWithIncompleteInfo() {
159+
void testParseRunwayWithNoInfo() throws ParseException {
160160
Metar m = new Metar();
161-
ParseException e = assertThrows(ParseException.class, () -> command.execute(m, "R16///////"));
162-
assertEquals(Messages.getInstance().getString("ErrorCode.IncompleteRunwayInformation"), e.getErrorCode().getMessage());
161+
162+
command.execute(m, "R16///////");
163+
assertThat(m.getRunways(), hasSize(1));
164+
RunwayInfo ri = m.getRunways().get(0);
165+
assertEquals("16", ri.getName());
166+
assertEquals(DepositType.NOT_REPORTED, ri.getDepositType());
167+
assertEquals(DepositCoverage.NOT_REPORTED, ri.getCoverage());
168+
}
169+
170+
@Test
171+
void testParseRunwayWithPartialInfo() throws ParseException {
172+
Metar m = new Metar();
173+
174+
command.execute(m, "R88/29////");
175+
assertThat(m.getRunways(), hasSize(1));
176+
RunwayInfo ri = m.getRunways().get(0);
177+
assertEquals("88", ri.getName());
178+
assertEquals(DepositType.WET_WATER_PATCHES, ri.getDepositType());
179+
assertEquals(DepositCoverage.FROM_51_TO_100, ri.getCoverage());
163180
}
164181
}

0 commit comments

Comments
 (0)