fmidev / fmi-avi-messageconverter-tac

Conversion module for aviation TAC messages
MIT License
1 stars 4 forks source link

Fix AIRMET/SIGMET level parsing #177

Open kasarit opened 11 months ago

kasarit commented 11 months ago

Currently parsing the following TAC does not work correctly:

EHAA AIRMET 1 VALID 281430/281530 EHDB-
EHAA AMSTERDAM FIR FRQ TCU OBS ENTIRE FIR FL100 STNR NC=

SigmetLevel uses the following branch to set the values:

regex="^(?<sfc>SFC)?/?(?<unit2>FL)(?<level2>[0-9]{3})$";
    m = Pattern.compile(regex).matcher(toMatch);
    if (m.matches()){
        token.identify(SIGMET_LEVEL);
        token.setParsedValue(LEVEL_MODIFIER, null);
        token.setParsedValue(VALUE, m.group("sfc"));
        token.setParsedValue(UNIT, m.group("sfc"));
        token.setParsedValue(VALUE2, m.group("level2"));
        token.setParsedValue(UNIT2, m.group("unit2"));
    }

where VALUE2 and UNIT2 have the relevant values.

Then in AIRMETTACParserBase (and probably SIGMETTACParserBase) the values are fetched like this:

String upperLimit = match.getParsedValue(VALUE2, String.class);
String upperUnit = match.getParsedValue(UNIT2, String.class);

.. when the value should actually be handled as a lowerLimit. Currently the correct branch is never hit.