diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 1cd5820f..f739567b 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -29,7 +29,7 @@ jobs: run: echo ${{ github.event.number }} > PR_NUMBER.txt - name: Upload the PR number as an artifact - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v3 with: name: PR_NUMBER path: PR_NUMBER.txt diff --git a/metarParser-commons/src/main/resources/internationalization/messages.properties b/metarParser-commons/src/main/resources/internationalization/messages.properties index ed5a53cd..f57f6697 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages.properties @@ -17,13 +17,14 @@ CloudType.SC=Stratocumulus CloudType.ST=Stratus CloudType.TCU=Towering cumulus -DepositBrakingCapacity.NOT_REPORTED=not reported -DepositBrakingCapacity.POOR=poor -DepositBrakingCapacity.MEDIUM_POOR=poor/medium -DepositBrakingCapacity.MEDIUM=medium -DepositBrakingCapacity.MEDIUM_GOOD=medium/good -DepositBrakingCapacity.GOOD=good -DepositBrakingCapacity.UNRELIABLE=figures unreliable +DepositBrakingCapacity.//=not reported +DepositBrakingCapacity.91=poor +DepositBrakingCapacity.92=poor/medium +DepositBrakingCapacity.93=medium +DepositBrakingCapacity.94=medium/good +DepositBrakingCapacity.95=good +DepositBrakingCapacity.99=figures unreliable +DepositBrakingCapacity.default=friction coefficient of {0} DepositCoverage.NOT_REPORTED=not reported DepositCoverage.LESS_10=less than 10% @@ -31,16 +32,17 @@ DepositCoverage.FROM_11_TO_25=from 11% to 25% DepositCoverage.FROM_26_TO_50=from 26% to 50% DepositCoverage.FROM_51_TO_100=from 51% to 100% -DepositThickness.NOT_REPORTED=not reported -DepositThickness.LESS_1_MM=less than 1 mm -DepositThickness.THICKNESS_10=10 cm -DepositThickness.THICKNESS_15=15 cm -DepositThickness.THICKNESS_20=20 cm -DepositThickness.THICKNESS_25=25 cm -DepositThickness.THICKNESS_30=30 cm -DepositThickness.THICKNESS_35=35 cm -DepositThickness.THICKNESS_40=40 cm or more -DepositThickness.CLOSED=closed +DepositThickness.//=not reported +DepositThickness.00=less than 1 mm +DepositThickness.92=10 cm +DepositThickness.93=15 cm +DepositThickness.94=20 cm +DepositThickness.95=25 cm +DepositThickness.96=30 cm +DepositThickness.97=35 cm +DepositThickness.98=40 cm or more +DepositThickness.99=closed +DepositThickness.default={0} mm DepositType.NOT_REPORTED=not reported DepositType.CLEAR_DRY=clear and dry diff --git a/metarParser-commons/src/main/resources/internationalization/messages_de.properties b/metarParser-commons/src/main/resources/internationalization/messages_de.properties index 58e2aa28..de54f26b 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_de.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_de.properties @@ -8,13 +8,13 @@ CloudQuantity.SKC=wolkenlos CloudType.CC=Cirrocumulus CloudType.TCU=turmartigen Cumulus -DepositBrakingCapacity.NOT_REPORTED=nicht gemeldet -DepositBrakingCapacity.POOR=schlecht -DepositBrakingCapacity.MEDIUM_POOR=schlecht/mäßig -DepositBrakingCapacity.MEDIUM=mäßig -DepositBrakingCapacity.MEDIUM_GOOD=mäßig/gut -DepositBrakingCapacity.GOOD=gut -DepositBrakingCapacity.UNRELIABLE=Werte unzuverlässig +DepositBrakingCapacity.//=nicht gemeldet +DepositBrakingCapacity.91=schlecht +DepositBrakingCapacity.92=schlecht/mäßig +DepositBrakingCapacity.93=mäßig +DepositBrakingCapacity.94=mäßig/gut +DepositBrakingCapacity.95=gut +DepositBrakingCapacity.99=Werte unzuverlässig DepositCoverage.NOT_REPORTED=nicht gemeldet DepositCoverage.LESS_10=weniger als 10% @@ -22,10 +22,10 @@ DepositCoverage.FROM_11_TO_25=von 11% bis 25% DepositCoverage.FROM_26_TO_50=von 26% bis 50% DepositCoverage.FROM_51_TO_100=von 51% bis 100% -DepositThickness.NOT_REPORTED=nicht gemeldet -DepositThickness.LESS_1_MM=weniger als 1 mm -DepositThickness.THICKNESS_40=40 cm oder mehr -DepositThickness.CLOSED=geschlossen +DepositThickness.//=nicht gemeldet +DepositThickness.00=weniger als 1 mm +DepositThickness.98=40 cm oder mehr +DepositThickness.99=geschlossen DepositType.NOT_REPORTED=nicht gemeldet DepositType.CLEAR_DRY=frei von Ablagerungen und trocken diff --git a/metarParser-commons/src/main/resources/internationalization/messages_es.properties b/metarParser-commons/src/main/resources/internationalization/messages_es.properties index eb781bf8..c9451cce 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_es.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_es.properties @@ -14,23 +14,23 @@ CloudType.SC=Stratocumulus CloudType.ST=Stratus CloudType.TCU=Torrecumulus -DepositBrakingCapacity.NOT_REPORTED=no reportado +DepositBrakingCapacity.//=no reportado DepositCoverage.LESS_10=menos de 10% DepositCoverage.FROM_11_TO_25=de 11% a 25% DepositCoverage.FROM_26_TO_50=de 26% a 50% DepositCoverage.FROM_51_TO_100=de 51% a 100% -DepositThickness.NOT_REPORTED=no reportado -DepositThickness.LESS_1_MM=menos de 1 mm +DepositThickness.//=no reportado +DepositThickness.00=menos de 1 mm DepositThickness.THICKNESS_10=10 cm DepositThickness.THICKNESS_15=15 cm DepositThickness.THICKNESS_20=20 cm DepositThickness.THICKNESS_25=25 cm DepositThickness.THICKNESS_30=30 cm DepositThickness.THICKNESS_35=35 cm -DepositThickness.THICKNESS_40=40 cm o más -DepositThickness.CLOSED=cerrado +DepositThickness.98=40 cm o más +DepositThickness.99=cerrado DepositType.NOT_REPORTED=no reportado DepositType.CLEAR_DRY=claro y seco diff --git a/metarParser-commons/src/main/resources/internationalization/messages_fr.properties b/metarParser-commons/src/main/resources/internationalization/messages_fr.properties index 9f70cb3a..c8d98a01 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_fr.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_fr.properties @@ -9,13 +9,13 @@ CloudType.CB=Cumunolinbus CloudType.CC=Cirrocumulus CloudType.TCU=Cumulus bourgeonnant -DepositBrakingCapacity.NOT_REPORTED=non reportée -DepositBrakingCapacity.POOR=mauvaise -DepositBrakingCapacity.MEDIUM_POOR=mauvaise/moyenne -DepositBrakingCapacity.MEDIUM=moyenne -DepositBrakingCapacity.MEDIUM_GOOD=moyenne/bonne -DepositBrakingCapacity.GOOD=bonne -DepositBrakingCapacity.UNRELIABLE=valeurs non fiables +DepositBrakingCapacity.//=non reportée +DepositBrakingCapacity.91=mauvaise +DepositBrakingCapacity.92=mauvaise/moyenne +DepositBrakingCapacity.93=moyenne +DepositBrakingCapacity.94=moyenne/bonne +DepositBrakingCapacity.95=bonne +DepositBrakingCapacity.99=valeurs non fiables DepositCoverage.NOT_REPORTED=non reportée DepositCoverage.LESS_10=moins de 10% @@ -23,10 +23,10 @@ DepositCoverage.FROM_11_TO_25=de 11% à 25% DepositCoverage.FROM_26_TO_50=de 26% à 50% DepositCoverage.FROM_51_TO_100=de 51% à 100% -DepositThickness.NOT_REPORTED=non reportée -DepositThickness.LESS_1_MM=moins de 1 mm -DepositThickness.THICKNESS_40=40 cm ou plus -DepositThickness.CLOSED=fermée +DepositThickness.//=non reportée +DepositThickness.00=moins de 1 mm +DepositThickness.98=40 cm ou plus +DepositThickness.99=fermée DepositType.NOT_REPORTED=non reportée DepositType.CLEAR_DRY=clair et sec diff --git a/metarParser-commons/src/main/resources/internationalization/messages_it.properties b/metarParser-commons/src/main/resources/internationalization/messages_it.properties index 9187656b..c15a673a 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_it.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_it.properties @@ -17,13 +17,13 @@ CloudType.SC=Stratocumulo CloudType.ST=Strato CloudType.TCU=Cumuli torreggiantidecreasing -DepositBrakingCapacity.NOT_REPORTED=non riportato -DepositBrakingCapacity.POOR=scarso -DepositBrakingCapacity.MEDIUM_POOR=medio/scarso -DepositBrakingCapacity.MEDIUM=medio -DepositBrakingCapacity.MEDIUM_GOOD=medio/buono -DepositBrakingCapacity.GOOD=buono -DepositBrakingCapacity.UNRELIABLE=cifre inaffidabili +DepositBrakingCapacity.//=non riportato +DepositBrakingCapacity.91=scarso +DepositBrakingCapacity.92=medio/scarso +DepositBrakingCapacity.93=medio +DepositBrakingCapacity.94=medio/buono +DepositBrakingCapacity.95=buono +DepositBrakingCapacity.99=cifre inaffidabili DepositCoverage.NOT_REPORTED=non riportato DepositCoverage.LESS_10=meno del 10% @@ -31,16 +31,16 @@ DepositCoverage.FROM_11_TO_25=dal 11% al 25% DepositCoverage.FROM_26_TO_50=dal 26% al 50% DepositCoverage.FROM_51_TO_100=dal 51% al 100% -DepositThickness.NOT_REPORTED=non riportato -DepositThickness.LESS_1_MM=meno di 1 mm +DepositThickness.//=non riportato +DepositThickness.00=meno di 1 mm DepositThickness.THICKNESS_10=10 cm DepositThickness.THICKNESS_15=15 cm DepositThickness.THICKNESS_20=20 cm DepositThickness.THICKNESS_25=25 cm DepositThickness.THICKNESS_30=30 cm DepositThickness.THICKNESS_35=35 cm -DepositThickness.THICKNESS_40=40 cm -DepositThickness.CLOSED=chiusa +DepositThickness.98=40 cm +DepositThickness.99=chiusa DepositType.NOT_REPORTED=non riportato DepositType.CLEAR_DRY=pulita e asciutta diff --git a/metarParser-commons/src/main/resources/internationalization/messages_tr_TR.properties b/metarParser-commons/src/main/resources/internationalization/messages_tr_TR.properties index e83bad07..7b06130b 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_tr_TR.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_tr_TR.properties @@ -17,13 +17,13 @@ CloudType.SC=Stratokümülüs CloudType.ST=Stratüs CloudType.TCU=Yükselen kümülüs -DepositBrakingCapacity.NOT_REPORTED=rapor edilmedi -DepositBrakingCapacity.POOR=kötü -DepositBrakingCapacity.MEDIUM_POOR=kötü/orta -DepositBrakingCapacity.MEDIUM=orta -DepositBrakingCapacity.MEDIUM_GOOD=orta/iyi -DepositBrakingCapacity.GOOD=iyi -DepositBrakingCapacity.UNRELIABLE=güvenilmez +DepositBrakingCapacity.//=rapor edilmedi +DepositBrakingCapacity.91=kötü +DepositBrakingCapacity.92=kötü/orta +DepositBrakingCapacity.93=orta +DepositBrakingCapacity.94=orta/iyi +DepositBrakingCapacity.95=iyi +DepositBrakingCapacity.99=güvenilmez DepositCoverage.NOT_REPORTED=rapor edilmedi DepositCoverage.LESS_10=%10'dan daha az @@ -31,16 +31,16 @@ DepositCoverage.FROM_11_TO_25=%11 ila %25 arası DepositCoverage.FROM_26_TO_50=%26 ila %50 arası DepositCoverage.FROM_51_TO_100=%51 ila %100 arası -DepositThickness.NOT_REPORTED=rapor edilmedi -DepositThickness.LESS_1_MM=1 mm'den daha az +DepositThickness.//=rapor edilmedi +DepositThickness.00=1 mm'den daha az DepositThickness.THICKNESS_10=10 cm DepositThickness.THICKNESS_15=15 cm DepositThickness.THICKNESS_20=20 cm DepositThickness.THICKNESS_25=25 cm DepositThickness.THICKNESS_30=30 cm DepositThickness.THICKNESS_35=35 cm -DepositThickness.THICKNESS_40=40 cm veya daha fazla -DepositThickness.CLOSED=kullanılmaz +DepositThickness.98=40 cm veya daha fazla +DepositThickness.99=kullanılmaz DepositType.NOT_REPORTED=rapor edilmedi DepositType.CLEAR_DRY=açık ve kuru diff --git a/metarParser-commons/src/main/resources/internationalization/messages_zh_CN.properties b/metarParser-commons/src/main/resources/internationalization/messages_zh_CN.properties index d8c9fe3e..75bbdf4b 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_zh_CN.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_zh_CN.properties @@ -17,13 +17,13 @@ CloudType.SC=层积云 CloudType.ST=层云 CloudType.TCU=高耸积云 -DepositBrakingCapacity.NOT_REPORTED=未报告 -DepositBrakingCapacity.POOR=差 -DepositBrakingCapacity.MEDIUM_POOR=中差 -DepositBrakingCapacity.MEDIUM=中 +DepositBrakingCapacity.//=未报告 +DepositBrakingCapacity.91=差 +DepositBrakingCapacity.92=中差 +DepositBrakingCapacity.93=中 DepositBrakingCapacity.MEDIUM_GOOD=良好 -DepositBrakingCapacity.GOOD=好 -DepositBrakingCapacity.UNRELIABLE=数字不可靠 +DepositBrakingCapacity.95=好 +DepositBrakingCapacity.99=数字不可靠 DepositCoverage.NOT_REPORTED=未报告 DepositCoverage.LESS_10=低于10% @@ -31,16 +31,16 @@ DepositCoverage.FROM_11_TO_25=从11%到25% DepositCoverage.FROM_26_TO_50=从26%到50% DepositCoverage.FROM_51_TO_100=从51%到100% -DepositThickness.NOT_REPORTED=未报告 -DepositThickness.LESS_1_MM=小于 1 毫米 +DepositThickness.//=未报告 +DepositThickness.00=小于 1 毫米 DepositThickness.THICKNESS_10=10 厘米 DepositThickness.THICKNESS_15=15 厘米 DepositThickness.THICKNESS_20=20 厘米 DepositThickness.THICKNESS_25=25 厘米 DepositThickness.THICKNESS_30=30 厘米 DepositThickness.THICKNESS_35=35 厘米 -DepositThickness.THICKNESS_40=40厘米或以上 -DepositThickness.CLOSED=已关闭 +DepositThickness.98=40厘米或以上 +DepositThickness.99=已关闭 DepositType.NOT_REPORTED=未报告 DepositType.CLEAR_DRY=干净 diff --git a/metarParser-entities/pom.xml b/metarParser-entities/pom.xml index 51bd7db8..13f2e129 100644 --- a/metarParser-entities/pom.xml +++ b/metarParser-entities/pom.xml @@ -13,7 +13,7 @@ Module containing the model of the application. - 0.83 + 0.82 0.90 0.63 diff --git a/metarParser-entities/src/main/java/io/github/mivek/enums/DepositBrakingCapacity.java b/metarParser-entities/src/main/java/io/github/mivek/enums/DepositBrakingCapacity.java deleted file mode 100644 index 3b5c2578..00000000 --- a/metarParser-entities/src/main/java/io/github/mivek/enums/DepositBrakingCapacity.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.mivek.enums; - -import io.github.mivek.internationalization.Messages; - -/** - * Represents the breaking capacity on the runway. - * @author mivek - */ -public enum DepositBrakingCapacity { - /** Not reported: '//'. */ - NOT_REPORTED, - /** 91. */ - POOR, - /** 92. */ - MEDIUM_POOR, - /** 93. */ - MEDIUM, - /** 94. */ - MEDIUM_GOOD, - /** 95. */ - GOOD, - /** 99. */ - UNRELIABLE; - - @Override - public String toString() { - return Messages.getInstance().getString("DepositBrakingCapacity." + name()); - } -} - diff --git a/metarParser-entities/src/main/java/io/github/mivek/enums/DepositThickness.java b/metarParser-entities/src/main/java/io/github/mivek/enums/DepositThickness.java deleted file mode 100644 index ad6c2abb..00000000 --- a/metarParser-entities/src/main/java/io/github/mivek/enums/DepositThickness.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.mivek.enums; - -import io.github.mivek.internationalization.Messages; - -/** - * Represent the thickness of the deposit on the runway. - * @author mivek - */ -public enum DepositThickness { - /** Not reported '//'. */ - NOT_REPORTED, - /** Less than 1mm: 00. */ - LESS_1_MM, - /** 10 cm.: 92. */ - THICKNESS_10, - /** 15 cm.: 93. */ - THICKNESS_15, - /** 20 cm. 94. */ - THICKNESS_20, - /** 25 cm. 95. */ - THICKNESS_25, - /** 30 cm. 96. */ - THICKNESS_30, - /** 35 cm. 97. */ - THICKNESS_35, - /** 40 cm or more. 98. */ - THICKNESS_40, - /** closed: 99. */ - CLOSED; - - @Override - public String toString() { - return Messages.getInstance().getString("DepositThickness." + name()); - } -} - diff --git a/metarParser-entities/src/main/java/io/github/mivek/model/RunwayInfo.java b/metarParser-entities/src/main/java/io/github/mivek/model/RunwayInfo.java index 06fd0ee2..3e712a86 100644 --- a/metarParser-entities/src/main/java/io/github/mivek/model/RunwayInfo.java +++ b/metarParser-entities/src/main/java/io/github/mivek/model/RunwayInfo.java @@ -1,8 +1,6 @@ package io.github.mivek.model; -import io.github.mivek.enums.DepositBrakingCapacity; import io.github.mivek.enums.DepositCoverage; -import io.github.mivek.enums.DepositThickness; import io.github.mivek.enums.DepositType; import io.github.mivek.enums.RunwayInfoIndicator; import io.github.mivek.enums.RunwayInfoTrend; @@ -30,9 +28,9 @@ public class RunwayInfo { /** The percentage of coverage. */ private DepositCoverage coverage; /** The thickness of the deposit. */ - private DepositThickness thickness; + private String thickness; /** The breaking capacity on the runway. */ - private DepositBrakingCapacity brakingCapacity; + private String brakingCapacity; /** * Getter of name. @@ -151,28 +149,28 @@ public void setCoverage(final DepositCoverage coverage) { /** * @return The thickness of the deposit. */ - public DepositThickness getThickness() { + public String getThickness() { return thickness; } /** * @param thickness The thickness to set. */ - public void setThickness(final DepositThickness thickness) { + public void setThickness(final String thickness) { this.thickness = thickness; } /** * @return The braking capacity on the runway. */ - public DepositBrakingCapacity getBrakingCapacity() { + public String getBrakingCapacity() { return brakingCapacity; } /** * @param brakingCapacity the braking capacity to set. */ - public void setBrakingCapacity(final DepositBrakingCapacity brakingCapacity) { + public void setBrakingCapacity(final String brakingCapacity) { this.brakingCapacity = brakingCapacity; } diff --git a/metarParser-entities/src/test/java/io/github/mivek/model/RunwayInfoTest.java b/metarParser-entities/src/test/java/io/github/mivek/model/RunwayInfoTest.java index fe842fbd..7c2d3a50 100644 --- a/metarParser-entities/src/test/java/io/github/mivek/model/RunwayInfoTest.java +++ b/metarParser-entities/src/test/java/io/github/mivek/model/RunwayInfoTest.java @@ -1,8 +1,8 @@ package io.github.mivek.model; -import io.github.mivek.enums.DepositBrakingCapacity; +import static org.hamcrest.MatcherAssert.assertThat; + import io.github.mivek.enums.DepositCoverage; -import io.github.mivek.enums.DepositThickness; import io.github.mivek.enums.DepositType; import io.github.mivek.enums.RunwayInfoIndicator; import io.github.mivek.enums.RunwayInfoTrend; @@ -10,8 +10,6 @@ import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; -import static org.hamcrest.MatcherAssert.assertThat; - class RunwayInfoTest { @Test @@ -23,8 +21,8 @@ void testToString() { ri.setMaxRange(500); ri.setDepositType(DepositType.COMPACTED_SNOW); ri.setCoverage(DepositCoverage.FROM_11_TO_25); - ri.setThickness(DepositThickness.THICKNESS_15); - ri.setBrakingCapacity(DepositBrakingCapacity.POOR); + ri.setThickness(Messages.getInstance().getString("DepositThickness.93")); + ri.setBrakingCapacity(Messages.getInstance().getString("DepositBrakingCapacity.91")); ri.setIndicator(RunwayInfoIndicator.LESS_THAN); String des = ri.toString(); @@ -35,8 +33,8 @@ void testToString() { assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.trend") + "=up rising")); assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.deposit.type") + "=" + Messages.getInstance().getString("DepositType.COMPACTED_SNOW"))); assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.deposit.coverage") + "=" + Messages.getInstance().getString("DepositCoverage.FROM_11_TO_25"))); - assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.deposit.thickness") + "=" + Messages.getInstance().getString("DepositThickness.THICKNESS_15"))); - assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.deposit.braking") + "=" + Messages.getInstance().getString("DepositBrakingCapacity.POOR"))); + assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.deposit.thickness") + "=" + Messages.getInstance().getString("DepositThickness.93"))); + assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.deposit.braking") + "=" + Messages.getInstance().getString("DepositBrakingCapacity.91"))); assertThat(des, Matchers.containsString(Messages.getInstance().getString("ToString.indicator") + "=less than")); } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java index e512f974..abf5ed68 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java @@ -1,11 +1,10 @@ package io.github.mivek.command.metar; -import io.github.mivek.enums.DepositBrakingCapacity; import io.github.mivek.enums.DepositCoverage; -import io.github.mivek.enums.DepositThickness; import io.github.mivek.enums.DepositType; import io.github.mivek.enums.RunwayInfoIndicator; import io.github.mivek.enums.RunwayInfoTrend; +import io.github.mivek.internationalization.Messages; import io.github.mivek.model.Metar; import io.github.mivek.model.RunwayInfo; import io.github.mivek.utils.Regex; @@ -50,35 +49,37 @@ public final class RunwayCommand implements Command { new AbstractMap.SimpleImmutableEntry<>("9", DepositCoverage.FROM_51_TO_100)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); /** Immutable map deposit thickness. */ - private static final Map DEPOSIT_THICKNESS_MAP = Stream.of( - new AbstractMap.SimpleImmutableEntry<>("//", DepositThickness.NOT_REPORTED), - new AbstractMap.SimpleImmutableEntry<>("00", DepositThickness.LESS_1_MM), - new AbstractMap.SimpleImmutableEntry<>("92", DepositThickness.THICKNESS_10), - new AbstractMap.SimpleImmutableEntry<>("93", DepositThickness.THICKNESS_15), - new AbstractMap.SimpleImmutableEntry<>("94", DepositThickness.THICKNESS_20), - new AbstractMap.SimpleImmutableEntry<>("95", DepositThickness.THICKNESS_25), - new AbstractMap.SimpleImmutableEntry<>("96", DepositThickness.THICKNESS_30), - new AbstractMap.SimpleImmutableEntry<>("97", DepositThickness.THICKNESS_35), - new AbstractMap.SimpleImmutableEntry<>("98", DepositThickness.THICKNESS_40), - new AbstractMap.SimpleImmutableEntry<>("99", DepositThickness.CLOSED)) + private static final Map DEPOSIT_THICKNESS_MAP = Stream.of( + new AbstractMap.SimpleImmutableEntry<>("//", "DepositThickness.//"), + new AbstractMap.SimpleImmutableEntry<>("00", "DepositThickness.00"), + new AbstractMap.SimpleImmutableEntry<>("92", "DepositThickness.92"), + new AbstractMap.SimpleImmutableEntry<>("93", "DepositThickness.93"), + new AbstractMap.SimpleImmutableEntry<>("94", "DepositThickness.94"), + new AbstractMap.SimpleImmutableEntry<>("95", "DepositThickness.95"), + new AbstractMap.SimpleImmutableEntry<>("96", "DepositThickness.96"), + new AbstractMap.SimpleImmutableEntry<>("97", "DepositThickness.97"), + new AbstractMap.SimpleImmutableEntry<>("98", "DepositThickness.98"), + new AbstractMap.SimpleImmutableEntry<>("99", "DepositThickness.99")) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); /** Immutable map of braking capacity. */ - private static final Map DEPOSIT_BRAKING_CAPACITY_MAP = Stream.of( - new AbstractMap.SimpleImmutableEntry<>("//", DepositBrakingCapacity.NOT_REPORTED), - new AbstractMap.SimpleImmutableEntry<>("91", DepositBrakingCapacity.POOR), - new AbstractMap.SimpleImmutableEntry<>("92", DepositBrakingCapacity.MEDIUM_POOR), - new AbstractMap.SimpleImmutableEntry<>("93", DepositBrakingCapacity.MEDIUM), - new AbstractMap.SimpleImmutableEntry<>("94", DepositBrakingCapacity.MEDIUM_GOOD), - new AbstractMap.SimpleImmutableEntry<>("95", DepositBrakingCapacity.GOOD), - new AbstractMap.SimpleImmutableEntry<>("99", DepositBrakingCapacity.UNRELIABLE)) + private static final Map DEPOSIT_BRAKING_CAPACITY_MAP = Stream.of( + new AbstractMap.SimpleImmutableEntry<>("//", "DepositBrakingCapacity.//"), + new AbstractMap.SimpleImmutableEntry<>("91", "DepositBrakingCapacity.91"), + new AbstractMap.SimpleImmutableEntry<>("92", "DepositBrakingCapacity.92"), + new AbstractMap.SimpleImmutableEntry<>("93", "DepositBrakingCapacity.93"), + new AbstractMap.SimpleImmutableEntry<>("94", "DepositBrakingCapacity.94"), + new AbstractMap.SimpleImmutableEntry<>("95", "DepositBrakingCapacity.95"), + new AbstractMap.SimpleImmutableEntry<>("99", "DepositBrakingCapacity.99")) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - + /** Message instance. */ + private final Messages messages; /** * Package private constructor. */ RunwayCommand() { + this.messages = Messages.getInstance(); } @Override @@ -91,8 +92,8 @@ public void execute(final Metar metar, final String part) { ri.setName(matches[1]); ri.setDepositType(DEPOSIT_TYPE_MAP.get(matches[2])); ri.setCoverage(DEPOSIT_COVERAGE_MAP.get(matches[3])); - ri.setThickness(DEPOSIT_THICKNESS_MAP.get(matches[4])); - ri.setBrakingCapacity(DEPOSIT_BRAKING_CAPACITY_MAP.get(matches[5])); + ri.setThickness(parseDepositThickness(matches[4])); + ri.setBrakingCapacity(parseDepositBrakingCapacity(matches[5])); metar.addRunwayInfo(ri); } else if (Regex.find(RUNWAY_REGEX, part)) { matches = Regex.pregMatch(RUNWAY_REGEX, part); @@ -111,6 +112,24 @@ public void execute(final Metar metar, final String part) { } } + /** + * Parses the deposit thickness according to the input. + * @param input The deposit thickness to parse. + * @return Translated sentence representing the deposit thickness. + */ + private String parseDepositThickness(final String input) { + return messages.getString(DEPOSIT_THICKNESS_MAP.getOrDefault(input, "DepositThickness.default"), input); + } + + /** + * Parses the braking capacity according to the input. + * If the input is not in the map then the default translation is used. + * @param input The braking capacity. + * @return Translated sentence representing the braking capacity. + */ + private String parseDepositBrakingCapacity(final String input) { + return messages.getString(DEPOSIT_BRAKING_CAPACITY_MAP.getOrDefault(input, "DepositBrakingCapacity.default"), Double.parseDouble(input) / 100); + } @Override public boolean canParse(final String input) { return Regex.find(GENERIC_RUNWAY_REGEX, input); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java index 1f16a5a8..4943b1e2 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java @@ -6,12 +6,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import io.github.mivek.enums.DepositBrakingCapacity; import io.github.mivek.enums.DepositCoverage; -import io.github.mivek.enums.DepositThickness; import io.github.mivek.enums.DepositType; import io.github.mivek.enums.RunwayInfoIndicator; import io.github.mivek.enums.RunwayInfoTrend; +import io.github.mivek.internationalization.Messages; import io.github.mivek.model.Metar; import io.github.mivek.model.RunwayInfo; import org.junit.jupiter.api.BeforeEach; @@ -104,8 +103,8 @@ void testParseRunwayDeposit() { assertEquals("05", ri.getName()); assertEquals(DepositType.SLUSH, ri.getDepositType()); assertEquals(DepositCoverage.FROM_11_TO_25, ri.getCoverage()); - assertEquals(DepositThickness.THICKNESS_10, ri.getThickness()); - assertEquals(DepositBrakingCapacity.MEDIUM_GOOD, ri.getBrakingCapacity()); + assertEquals(Messages.getInstance().getString("DepositThickness.92"), ri.getThickness()); + assertEquals(Messages.getInstance().getString("DepositBrakingCapacity.94"), ri.getBrakingCapacity()); } @Test @@ -119,8 +118,8 @@ void testParseRunwayDepositWithNotReportedType() { assertEquals("05", ri.getName()); assertEquals(DepositType.NOT_REPORTED, ri.getDepositType()); assertEquals(DepositCoverage.FROM_11_TO_25, ri.getCoverage()); - assertEquals(DepositThickness.THICKNESS_10, ri.getThickness()); - assertEquals(DepositBrakingCapacity.MEDIUM_GOOD, ri.getBrakingCapacity()); + assertEquals(Messages.getInstance().getString("DepositThickness.92"), ri.getThickness()); + assertEquals(Messages.getInstance().getString("DepositBrakingCapacity.94"), ri.getBrakingCapacity()); } @Test diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java index d1c7de64..60c96989 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java @@ -436,4 +436,19 @@ void testParseVC() { assertEquals(Descriptive.BLOWING, m.getWeatherConditions().get(2).getDescriptive()); assertEquals(Phenomenon.SNOW, m.getWeatherConditions().get(2).getPhenomenons().get(0)); } + + @Test + void testParseRunwayDeposit() { + String code = "UUDD 212100Z 20005MPS 8000 -FZRA SCT005 M01/M02 Q1010 R14R/590335 NOSIG"; + + Messages.getInstance().setLocale(Locale.ENGLISH); + Metar m = parser.parse(code); + assertEquals("UUDD", m.getStation()); + assertThat(m.getRunways(), hasSize(1)); + assertEquals("14R", m.getRunways().get(0).getName()); + assertEquals(DepositType.WET_SNOW, m.getRunways().get(0).getDepositType()); + assertEquals(DepositCoverage.FROM_51_TO_100, m.getRunways().get(0).getCoverage()); + assertEquals("03 mm", m.getRunways().get(0).getThickness()); + assertEquals("friction coefficient of 0.35", m.getRunways().get(0).getBrakingCapacity()); + } }