diff --git a/.github/workflows/build_sonar_verify.yml b/.github/workflows/build_sonar_verify.yml index 49a4c7d5..97f51cc4 100644 --- a/.github/workflows/build_sonar_verify.yml +++ b/.github/workflows/build_sonar_verify.yml @@ -16,13 +16,13 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '17' distribution: 'adopt' cache: 'maven' - name: Cache SonarCloud packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar diff --git a/.github/workflows/bump-pom.yml b/.github/workflows/bump-pom.yml index 0c072cef..d32c220f 100644 --- a/.github/workflows/bump-pom.yml +++ b/.github/workflows/bump-pom.yml @@ -45,7 +45,7 @@ jobs: - name: Retrieve the new version id: get-version - uses: JActions/maven-version@v1.0.0 + uses: JActions/maven-version@v1.0.1 - name: Commit and tag the new version uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bf794250..93f9c4b4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -50,7 +50,7 @@ jobs: - name: Retrieve the version id: get-version - uses: JActions/maven-version@v1.0.0 + uses: JActions/maven-version@v1.0.1 - name: Create the release uses: marvinpinto/action-automatic-releases@latest diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml index 6c91dbe3..31d8b477 100644 --- a/.github/workflows/manual-deploy.yml +++ b/.github/workflows/manual-deploy.yml @@ -59,7 +59,7 @@ jobs: - name: Retrieve the version id: get-version - uses: JActions/maven-version@v1.0.0 + uses: JActions/maven-version@v1.0.1 - name: Create the release uses: marvinpinto/action-automatic-releases@latest diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 0f1ff481..190da467 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -8,16 +8,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '17' distribution: 'adopt' - name: Cache maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} diff --git a/metarParser-commons/src/main/resources/internationalization/messages.properties b/metarParser-commons/src/main/resources/internationalization/messages.properties index 8a6b51e6..55998f99 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages.properties @@ -67,6 +67,12 @@ Error.prefix=An error occured. Error code n° ErrorCode.AirportNotFound=The airport was not found for this message. ErrorCode.InvalidMessage=The entered message is invalid. +Flag.AMD=amended TAF +Flag.AUTO=automated METAR +Flag.CNL=canceled TAF +Flag.COR=corrected METAR/TAF +Flag.NIL=no data + Indicator.M=less than Indicator.P=greater than @@ -216,6 +222,7 @@ ToString.descriptive=descriptive ToString.dew.point=dew point ToString.end.day.month=end day of the month ToString.end.hour.day=end hour of the day +ToString.flags=flags ToString.height.feet=height (ft) ToString.height.meter=height (m) ToString.intensity=intensity diff --git a/metarParser-commons/src/main/resources/internationalization/messages_de.properties b/metarParser-commons/src/main/resources/internationalization/messages_de.properties index a54379d5..4359f4a7 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_de.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_de.properties @@ -51,6 +51,7 @@ Error.prefix=Ein Fehler ist aufgetretten. Error Code n° ErrorCode.AirportNotFound=Der Flughafen wurde in dieser Mitteilung nicht gefunden ErrorCode.InvalidMessage=Eingegebende Mitteilung nicht gültig + Indicator.M=weniger als Indicator.P=mehr als diff --git a/metarParser-commons/src/main/resources/internationalization/messages_fr.properties b/metarParser-commons/src/main/resources/internationalization/messages_fr.properties index 10da1a68..f946e1bf 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_fr.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_fr.properties @@ -5,8 +5,16 @@ CloudQuantity.OVC=ciel couvert CloudQuantity.SCT=nuages épars CloudQuantity.SKC=pas de nuage +CloudType.AC=Altocumulus +CloudType.AS=Altostratus CloudType.CB=Cumunolinbus CloudType.CC=Cirrocumulus +CloudType.CI=Cirrus +CloudType.CS=Cirrostratus +CloudType.CU=Cumulus +CloudType.NS=Nimbostratus +CloudType.SC=Stratocumulus +CloudType.ST=Stratus CloudType.TCU=Cumulus bourgeonnant DepositBrakingCapacity.NOT_REPORTED=non reportée @@ -25,6 +33,12 @@ DepositCoverage.FROM_51_TO_100=de 51% à 100% DepositThickness.NOT_REPORTED=non reportée DepositThickness.LESS_1_MM=moins 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 ou plus DepositThickness.CLOSED=fermée @@ -53,6 +67,12 @@ Error.prefix=Une erreur est survenue. Code erreur n° ErrorCode.AirportNotFound=L'aéroport n'a pas été trouvé pour ce message. ErrorCode.InvalidMessage=Le message entré est invalide. +Flag.AMD=TAF modifié +Flag.AUTO=METAR automatisé +Flag.CNL=TAF annulé +Flag.COR=METAR/TAF corrigé +Flag.NIL=Aucune donnée + Indicator.M=moins que Indicator.P=plus que @@ -73,6 +93,7 @@ Phenomenon.HZ=brume sèche Phenomenon.IC=cristaux de glace Phenomenon.PL=granules de glace Phenomenon.PO=tourbillon de poussières sable +Phenomenon.PY=spray Phenomenon.RA=pluie Phenomenon.SA=sable Phenomenon.SG=neige en grains @@ -145,6 +166,7 @@ Remark.Tower.Visibility=visibility de la tour de contrôle de {0} miles Remark.Variable.Prevailing.Visibility=variation de la visibilité dominante entre {0} et {1} SM Remark.Variable.Sky.Condition=couche de nuages variant entre {0} et {1} Remark.Variable.Sky.Condition.Height=couche de nuages à {0} pieds variant entre {1} et {2} +Remark.VIRGA=virga Remark.Virga.Direction=virga au {0} de la station Remark.WATERSPOUT=trombe Remark.Water.Equivalent.Snow.Ground=équivalent d''eau de {0} pouces de neige @@ -170,6 +192,7 @@ Converter.SSE=Sud Sud Est Converter.SSW=Sud Sud Ouest Converter.SW=Sud Ouest Converter.U=accroissement +Converter.VRB=Variable Converter.W=Ouest Converter.WNW=Ouest Nord Ouest Converter.WSW=Ouest Sud Ouest @@ -186,6 +209,8 @@ TimeIndicator.TL=jusqu'à ToString.airport=aéroport ToString.altimeter=altimètre (hPa) ToString.amendment=amendement +ToString.auto=auto +ToString.cavok=cavok ToString.clouds=nuages ToString.day.month=jour du mois ToString.day.hour=heure du jour @@ -197,12 +222,14 @@ ToString.descriptive=descriptif ToString.dew.point=point de rosée ToString.end.day.month=jour de fin du mois ToString.end.hour.day=heure de fin du jour +ToString.flags=drapeaux ToString.height.feet=altitude (pieds) ToString.height.meter=altitude (m) ToString.intensity=intensité ToString.indicator=indicateur ToString.message=message original ToString.name=nom +ToString.nosig=nosig ToString.phenomenons=phénomènes ToString.probability=probabilité ToString.quantity=quantité @@ -217,12 +244,14 @@ ToString.temperature.max=température maximale (°C) ToString.temperature.min=température minimale (°C) ToString.trend=tendance ToString.trends=tendances +ToString.type=type ToString.visibility.main=visibilité principale ToString.visibility.min=visibilité minimale ToString.visibility.min.direction=direction de la visibilité minimale ToString.visibility.max=visibilité maximale ToString.vertical.visibility=visibilité verticale (pieds) ToString.weather.conditions=conditions météorologique +ToString.wind.direction=direction ToString.wind.direction.degrees=direction (degrés) ToString.wind.gusts=rafales ToString.wind.min.variation=variation minimale du vent diff --git a/metarParser-commons/src/main/resources/internationalization/messages_it.properties b/metarParser-commons/src/main/resources/internationalization/messages_it.properties index cf07f46a..9187656b 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_it.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_it.properties @@ -66,6 +66,7 @@ Error.prefix=Si è verificato un errore. Errore nr. ErrorCode.AirportNotFound=L’aeroporto non è stato trovato in questa notifica ErrorCode.InvalidMessage=Il messaggio non è valido + Indicator.M=minore di Indicator.P=maggiore di diff --git a/metarParser-commons/src/main/resources/internationalization/messages_pl_PL.properties b/metarParser-commons/src/main/resources/internationalization/messages_pl_PL.properties index 587889c0..d286d0c5 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_pl_PL.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_pl_PL.properties @@ -17,6 +17,10 @@ CloudType.SC=Kłębiasto warstwowa CloudType.ST=Warstwowa CloudType.TCU=Wypiętrzona chmura kłębiasta + + + + Descriptive.BC=płaty Descriptive.BL=zawieja Descriptive.DR=zamieć przyziemna @@ -30,6 +34,8 @@ Error.prefix=Wystąpił błąd. Kod błędu numer ErrorCode.AirportNotFound=Nie znaleziono lotniska w tej depeszy. ErrorCode.InvalidMessage=Wprowadzona depesza jest nieprawidłowa. + + Intensity.-=Słaby Intensity.+=Silny Intensity.VC=W pobliżu 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 9c63fc6c..fd8fb39a 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_tr_TR.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_tr_TR.properties @@ -67,6 +67,7 @@ Error.prefix=Hata oluştu. Hata kodu\: {0} ErrorCode.AirportNotFound=Bu mesaj için havaalanı bulunamadı. ErrorCode.InvalidMessage=Girilen mesaj geçersiz. + Indicator.M=daha az Indicator.P=daha fazla 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 daac3b14..d8c9fe3e 100644 --- a/metarParser-commons/src/main/resources/internationalization/messages_zh_CN.properties +++ b/metarParser-commons/src/main/resources/internationalization/messages_zh_CN.properties @@ -1,8 +1,8 @@ -CloudQuantity.BKN=碎云 -CloudQuantity.FEW=少量 +CloudQuantity.BKN=5-7分云 +CloudQuantity.FEW=少云 CloudQuantity.NSC=没有明显的云。 -CloudQuantity.OVC=多云 -CloudQuantity.SCT=散云 +CloudQuantity.OVC=满天云 +CloudQuantity.SCT=3-4分云 CloudQuantity.SKC=天空晴朗 CloudType.AC=高积云 @@ -17,9 +17,42 @@ CloudType.SC=层积云 CloudType.ST=层云 CloudType.TCU=高耸积云 - - - +DepositBrakingCapacity.NOT_REPORTED=未报告 +DepositBrakingCapacity.POOR=差 +DepositBrakingCapacity.MEDIUM_POOR=中差 +DepositBrakingCapacity.MEDIUM=中 +DepositBrakingCapacity.MEDIUM_GOOD=良好 +DepositBrakingCapacity.GOOD=好 +DepositBrakingCapacity.UNRELIABLE=数字不可靠 + +DepositCoverage.NOT_REPORTED=未报告 +DepositCoverage.LESS_10=低于10% +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.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=已关闭 + +DepositType.NOT_REPORTED=未报告 +DepositType.CLEAR_DRY=干净 +DepositType.DAMP=潮湿 +DepositType.WET_WATER_PATCHES=湿和水纹 +DepositType.RIME_FROST_COVERED=雾凇和霜覆盖 +DepositType.DRY_SNOW=干雪 +DepositType.WET_SNOW=湿雪 +DepositType.ICE=冰 +DepositType.COMPACTED_SNOW=压实或滚压的雪 +DepositType.FROZEN_RIDGES=冷冻的轮辙或冰脊 +DepositType.SLUSH=雪浆 Descriptive.BC=补丁 Descriptive.BL=吹 @@ -35,8 +68,11 @@ ErrorCode.AirportNotFound=找不到此消息的机场。 ErrorCode.InvalidMessage=输入的消息无效。 -Intensity.-=光 -Intensity.+=重的 +Indicator.M=小于 +Indicator.P=大于 + +Intensity.-=弱的 +Intensity.+=强的 Intensity.VC=在附近 Phenomenon.BR=薄雾 @@ -65,32 +101,125 @@ Phenomenon.TS=雷雨 Remark.AO1=没有降水鉴别器的自动化站 Remark.AO2=带有降水鉴别器的自动化站 +Remark.ALQDS=全象限 +Remark.Barometer.0=先增加后减少 +Remark.Barometer.1=先增加后稳定, 或是先增加后缓慢增加 +Remark.Barometer.2=稳定或不稳定的增加 +Remark.Barometer.3=先减少或保持稳定,然后增加;或先增加然后快速增加 +Remark.Barometer.4=稳定 +Remark.Barometer.5=减小,然后增加 +Remark.Barometer.6=先减少后稳定;或先减少后更缓慢减少 +Remark.Barometer.7=稳定或不稳定地减少 +Remark.Barometer.8=先稳定或增加,然后减少;或先减少快速减少 Remark.BASED=基于 Remark.Ceiling.Height=上限在 {0} 到 {1} 英尺之间变化 Remark.Ceiling.Second.Location=由位于 {1} 处的第二个传感器测量的 {0} 英尺的上限 +Remark.DSNT=距离 Remark.FCST=预报 -Remark.FUNNELCLOUD=漏斗云 +Remark.FUNNELCLOUD=漏斗云 +Remark.Hail=直径为 {0} 英寸的最大的冰雹 +Remark.Hail.LesserThan=直径小于 {0} 英寸的最大的冰雹 +Remark.Hourly.Maximum.Temperature=6小时最高温度为{0}°C +Remark.Hourly.Maximum.Minimum.Temperature=24小时最高温度为{0}°C,24小时最低温度为{1}°C +Remark.Hourly.Minimum.Temperature=6 小时最低温度为 {0}° C +Remark.Hourly.Temperature=小时气温 {0}°C +Remark.Hourly.Temperature.Dew.Point=小时气温为{0}°C,露点为{1}°C +Remark.Ice.Accretion.Amount=过去{1} 小时内积冰{0}/100英寸 +Remark.HVY=重度的 +Remark.LGT=轻微的 +Remark.LTG=闪电 +Remark.MOD=中等 +Remark.Obscuration={0} 层位于 {1} 英尺,由 {2} 组成 +Remark.ON=在 +Remark.NXT=下一个 +Remark.PeakWind=在 {2}\:{3} 有位于 {0} 度,风速 {1} 节的峰值风 +Remark.TORNADO=龙卷风 +Remark.VIRGA=幡状云 +Remark.WATERSPOUT=水龙卷 +Remark.Water.Equivalent.Snow.Ground=相当于{0} 英寸雪的降水 +Remark.WindShift=风力转变于 {0}\:{1} MetarFacade.InvalidIcao=ICAO 代码无效。 Converter.D=减少 Converter.E=东 +Converter.ENE=东东北 +Converter.ESE=东东南 Converter.N=北 Converter.NE=东北 +Converter.NNE=北东北 +Converter.NNW=北西北 Converter.NSC=无明显变化 Converter.NW=西北 Converter.S=南 Converter.SE=东南 +Converter.SSE=南东南 +Converter.SSW=南西南 Converter.SW=西南 Converter.U=上升 Converter.VRB=多变的 Converter.W=西 +Converter.WNW=西西北 +Converter.WSW=西西南 WeatherChangeType.FM=从 WeatherChangeType.BECMG=变得 +WeatherChangeType.INTER=间歇的 WeatherChangeType.TEMPO=暂时的 WeatherChangeType.PROB=可能性 TimeIndicator.AT=在 +TimeIndicator.FM=从 TimeIndicator.TL=直到 +ToString.airport=机场 +ToString.altimeter=修正海压(百帕) +ToString.amendment=修订 +ToString.auto=自动观测 +ToString.cavok=能见度≥10km +ToString.clouds=云 +ToString.day.month=当月某天 +ToString.day.hour=当日某小时 +ToString.deposit.braking=制动能力 +ToString.deposit.coverage=覆盖范围 +ToString.deposit.thickness=厚度 +ToString.deposit.type=沉积物类型 +ToString.descriptive=描述 +ToString.dew.point=露点 +ToString.end.day.month=当月的结束日 +ToString.end.hour.day=当日的结束小时 +ToString.height.feet=高度(英尺) +ToString.height.meter=高度(米) +ToString.intensity=强度 +ToString.indicator=指示器 +ToString.message=原始消息 +ToString.name=名称 +ToString.nosig=无重大变化 +ToString.phenomenons=现象 +ToString.probability=可能性 +ToString.quantity=数量 +ToString.remark=备注 +ToString.report.time=报告时间 +ToString.runway.info=跑道信息 +ToString.start.day.month=当月起始日 +ToString.start.hour.day=当日起始小时 +ToString.start.minute=起始分钟 +ToString.temperature=温度(°C) +ToString.temperature.max=最高温度(°C) +ToString.temperature.min=最低温度(°C) +ToString.trend=趋势预报 +ToString.trends=趋势 +ToString.type=类型 +ToString.visibility.main=主要能见度 +ToString.visibility.min=最小能见度 +ToString.visibility.min.direction=最小能见方向 +ToString.visibility.max=最大能见度 +ToString.vertical.visibility=垂直能见度(英尺) +ToString.weather.conditions=天气状况 +ToString.wind.direction=方向 +ToString.wind.direction.degrees=方向(度) +ToString.wind.gusts=阵风 +ToString.wind.min.variation=最小风力变化量 +ToString.wind.max.variation=最大风力变化量 +ToString.wind.speed=速度 +ToString.wind.unit=单位 diff --git a/metarParser-entities/src/main/java/io/github/mivek/enums/Flag.java b/metarParser-entities/src/main/java/io/github/mivek/enums/Flag.java new file mode 100644 index 00000000..2ef27572 --- /dev/null +++ b/metarParser-entities/src/main/java/io/github/mivek/enums/Flag.java @@ -0,0 +1,26 @@ +package io.github.mivek.enums; + +import io.github.mivek.internationalization.Messages; + +/** + * Enumeration class for WeatherCode flags. + * + * @author Jean-Kevin KPADEY + */ +public enum Flag { + /** Amended. */ + AMD, + /** Auto. */ + AUTO, + /** Cancelled. */ + CNL, + /** Corrected. */ + COR, + /** Null. */ + NIL; + + @Override + public String toString() { + return Messages.getInstance().getString("Flag." + name()); + } +} diff --git a/metarParser-entities/src/main/java/io/github/mivek/model/AbstractWeatherCode.java b/metarParser-entities/src/main/java/io/github/mivek/model/AbstractWeatherCode.java index 4c88abbf..7f949157 100644 --- a/metarParser-entities/src/main/java/io/github/mivek/model/AbstractWeatherCode.java +++ b/metarParser-entities/src/main/java/io/github/mivek/model/AbstractWeatherCode.java @@ -1,6 +1,9 @@ package io.github.mivek.model; +import io.github.mivek.enums.Flag; import io.github.mivek.internationalization.Messages; +import java.util.EnumSet; +import java.util.Set; import org.apache.commons.lang3.builder.ToStringBuilder; import java.time.LocalTime; @@ -22,6 +25,16 @@ public abstract class AbstractWeatherCode extends AbstractWeatherContainer { /** The identifier of the station. */ private String station; + /** Holds the flag of the code. */ + private final EnumSet flags; + + /** + * Default constructor. + */ + protected AbstractWeatherCode() { + super(); + flags = EnumSet.noneOf(Flag.class); + } /** * @return the day */ @@ -92,6 +105,48 @@ public void setStation(final String station) { this.station = station; } + /** + * @return The flags of the weatherCode. + */ + public Set getFlags() { + return flags; + } + + /** + * @return the auto + */ + public boolean isAuto() { + return getFlags().contains(Flag.AUTO); + } + + /** + * @return the amendment + */ + public boolean isAmendment() { + return getFlags().contains(Flag.AMD); + } + + /** + * @return True when the code is canceled. + */ + public boolean isCancelled() { + return getFlags().contains(Flag.CNL); + } + + /** + * @return Return true if the code is nil. + */ + public boolean isNil() { + return getFlags().contains(Flag.NIL); + } + + /** + * @return True if the code is corrected. + */ + public boolean isCorrected() { + return getFlags().contains(Flag.COR); + } + /** * @return a description of the object. */ @@ -103,6 +158,7 @@ public String toString() { append(Messages.getInstance().getString("ToString.airport"), airport). appendSuper(super.toString()). append(Messages.getInstance().getString("ToString.message"), message). + append(Messages.getInstance().getString("ToString.flags"), flags). toString(); } } diff --git a/metarParser-entities/src/main/java/io/github/mivek/model/Metar.java b/metarParser-entities/src/main/java/io/github/mivek/model/Metar.java index 433f31e0..e9143266 100644 --- a/metarParser-entities/src/main/java/io/github/mivek/model/Metar.java +++ b/metarParser-entities/src/main/java/io/github/mivek/model/Metar.java @@ -22,8 +22,6 @@ public class Metar extends AbstractWeatherCode { private int altimeter; /** Nosig value. */ private boolean nosig; - /** Auto Value. */ - private boolean auto; /** List of runways information. */ private final List runways; /** List of trends. */ @@ -110,20 +108,6 @@ public void setNosig(final boolean nosig) { this.nosig = nosig; } - /** - * @return the auto - */ - public boolean isAuto() { - return auto; - } - - /** - * @param auto the auto to set - */ - public void setAuto(final boolean auto) { - this.auto = auto; - } - /** * Adds a trend to the list. * @@ -148,7 +132,7 @@ public final String toString() { append(Messages.getInstance().getString("ToString.dew.point"), dewPoint). append(Messages.getInstance().getString("ToString.altimeter"), altimeter). append(Messages.getInstance().getString("ToString.nosig"), nosig). - append(Messages.getInstance().getString("ToString.auto"), auto). + append(Messages.getInstance().getString("ToString.auto"), isAuto()). append(Messages.getInstance().getString("ToString.runway.info"), runways.toString()). append(Messages.getInstance().getString("ToString.trends"), trends.toString()). toString(); diff --git a/metarParser-entities/src/main/java/io/github/mivek/model/TAF.java b/metarParser-entities/src/main/java/io/github/mivek/model/TAF.java index 37413af1..b83d6269 100644 --- a/metarParser-entities/src/main/java/io/github/mivek/model/TAF.java +++ b/metarParser-entities/src/main/java/io/github/mivek/model/TAF.java @@ -26,8 +26,6 @@ public final class TAF extends AbstractWeatherCode { private TemperatureDated minTemperature; /** List of From changes. */ private final List> trends; - /** Indicate if the taf event is amended. */ - private boolean amendment; /** * Constructor. @@ -114,20 +112,6 @@ public List getInters() { return trends.stream().filter(trend -> trend.getType().equals(WeatherChangeType.INTER)).map(TafTrend.class::cast).toList(); } - /** - * @return the amendment - */ - public boolean isAmendment() { - return amendment; - } - - /** - * @param amendment the amendment to set - */ - public void setAmendment(final boolean amendment) { - this.amendment = amendment; - } - /** * Adds a trend to the trend list. * @param trend The trend to add. @@ -139,7 +123,7 @@ public void addTrend(final AbstractTafTrend trend) { @Override public String toString() { return new ToStringBuilder(this).appendSuper(super.toString()).appendToString(validity.toString()).append(Messages.getInstance().getString("ToString.temperature.max"), maxTemperature) - .append(Messages.getInstance().getString("ToString.temperature.min"), minTemperature).append(Messages.getInstance().getString("ToString.amendment"), amendment) + .append(Messages.getInstance().getString("ToString.temperature.min"), minTemperature).append(Messages.getInstance().getString("ToString.amendment"), isAmendment()) .appendToString(trends.toString()).toString(); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractWeatherCodeParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractWeatherCodeParser.java index acb21dc1..7b56ef0b 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractWeatherCodeParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractWeatherCodeParser.java @@ -2,6 +2,7 @@ import io.github.mivek.command.AirportSupplier; import io.github.mivek.command.common.CommonCommandSupplier; +import io.github.mivek.enums.Flag; import io.github.mivek.model.AbstractWeatherCode; import java.time.LocalTime; import java.util.Objects; @@ -53,6 +54,21 @@ void parseDeliveryTime(final AbstractWeatherCode weatherCode, final String time) weatherCode.setTime(t); } + /** + * Adds flags to the WeatherCode. + * @param weatherCode The weathercode to update + * @param flag The string to test. + * @return True if the flag was added. + */ + boolean parseFlags(final AbstractWeatherCode weatherCode, final String flag) { + try { + weatherCode.getFlags().add(Flag.valueOf(flag)); + return true; + } catch (IllegalArgumentException ignored) { + return false; + } + } + /** * Splits a string between spaces except if the space is between two digits with * SM. diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java index 7ca31f31..4050a581 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java @@ -74,11 +74,9 @@ public Metar parse(final String code) { int metarTabLength = metarTab.length; int i = 2; while (i < metarTabLength) { - if (!generalParse(m, metarTab[i])) { + if (!generalParse(m, metarTab[i]) && !parseFlags(m, metarTab[i])) { if ("NOSIG".equals(metarTab[i])) { m.setNosig(true); - } else if ("AUTO".equals(metarTab[i])) { - m.setAuto(true); } else if (RMK.equals(metarTab[i])) { parseRMK(m, metarTab, i); break; diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java index 75e56dcd..71cc2801 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java @@ -68,8 +68,7 @@ public TAF parse(final String code) throws ParseException { i = 2; } // Handle case the taf event is AMD. - if ("AMD".equals(line1parts[i])) { - taf.setAmendment(true); + if (parseFlags(taf, line1parts[i])) { i++; } // Airport @@ -95,6 +94,7 @@ public TAF parse(final String code) throws ParseException { } else if (part.startsWith(TN)) { taf.setMinTemperature(parseTemperature(part)); } else { + parseFlags(taf, part); generalParse(taf, part); } } 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 320d3bdd..54d736a3 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 @@ -402,4 +402,11 @@ void testParseWithMinimalVisibility() { assertEquals(2000, m.getVisibility().getMinVisibility()); assertEquals("SW", m.getVisibility().getMinDirection()); } + + @Test + void testParseNil() { + String code = "SVMC 211703Z AUTO NIL"; + Metar m = parser.parse(code); + assertTrue(m.isNil()); + } } diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java index 59eec51e..ba6374cb 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java @@ -785,4 +785,21 @@ void testParse() throws ParseException { assertEquals("P9SM", taf.getFMs().get(3).getVisibility().getMainVisibility()); } + @Test + void testParseCanceled() throws ParseException { + String code = "TAF VTBD 281000Z 2812/2912 CNL="; + + TAF taf = parser.parse(code); + + assertTrue(taf.isCancelled()); + } + + @Test + void testParseCorrected() throws ParseException { + String code = "TAF COR EDDS 201148Z 2012/2112 31010KT CAVOK BECMG 2018/2021 33004KT BECMG 2106/2109 07005KT"; + + TAF taf = parser.parse(code); + + assertTrue(taf.isCorrected()); + } } diff --git a/model.png b/model.png index 2d2496a7..b9d9aba3 100644 Binary files a/model.png and b/model.png differ diff --git a/pom.xml b/pom.xml index 96e7086e..bf768910 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ 0.96 0.97 0.23.1 - 10.3 + 10.3.1 3.12.0 2.2 0.8.8 @@ -63,13 +63,13 @@ 3.3.0 3.12.0 3.2.1 - 3.0.0-M6 + 3.0.0-M7 1.6.13 5.6 - 0.15 - 1.8.0 + 1.0.0 + 1.9.3 1.7.36 - 4.7.0.0 + 4.7.1.0 mivek-github https://sonarcloud.io