1+ /*
2+ * Copyright (c) 2019-2026 John Caron and University Corporation for Atmospheric Research/Unidata
3+ * See LICENSE for license information.
4+ */
5+
16package ucar .nc2 .grib .grib2 .table ;
27
38import com .google .common .collect .ImmutableList ;
2126public class WmoCodeFlagTables {
2227
2328 private static final org .slf4j .Logger logger = org .slf4j .LoggerFactory .getLogger (WmoCodeFlagTables .class );
24- public static final Version standard = Version .GRIB2_22_0_0 ;
29+ public static final Version standard = Version .GRIB2_37 ;
2530
2631 public enum Version {
27- GRIB2_22_0_0 ;
32+ GRIB2_37 ;
2833
2934 public String getResourceName () {
30- return "/resources/grib2/wmo/" + this .name () + "_CodeFlag_exp_en .xml" ;
35+ return "/resources/grib2/wmo/" + this .name () + "_CodeFlag .xml" ;
3136 }
3237
3338 @ Nullable
3439 String [] getElemNames () {
35- if (this == GRIB2_22_0_0 ) {
36- return new String [] {"GRIB2_22_0_0_CodeFlag_exp_en " , "Title_en" , "SubTitle_en" ,
40+ if (this == GRIB2_37 ) {
41+ return new String [] {"GRIB2_CodeFlag_en " , "Title_en" , "SubTitle_en" ,
3742 "MeaningParameterDescription_en" , "UnitComments_en" };
3843 }
3944
@@ -109,7 +114,7 @@ public WmoParamTable getParamTable(int discipline, int category) {
109114
110115 /*
111116 * Param Table:
112- * <GRIB2_22_0_0_CodeFlag_exp_en >
117+ * <GRIB2_CodeFlag_exp_en >
113118 * <No>524</No>
114119 * <Title_en>Code table 4.2 - Parameter number by product discipline and parameter category</Title_en>
115120 * <SubTitle_en>Product discipline 0 - Meteorological products, parameter category 1: moisture</SubTitle_en>
@@ -118,36 +123,36 @@ public WmoParamTable getParamTable(int discipline, int category) {
118123 * <UnitComments_en>kg-1</UnitComments_en>
119124 * <ElementDescription_en>Number of particles per unit mass of air</ElementDescription_en>
120125 * <Status>Operational</Status>
121- * </GRIB2_22_0_0_CodeFlag_exp_en >
126+ * </GRIB2_CodeFlag_exp_en >
122127 *
123128 * Code Table:
124- * <GRIB2_22_0_0_CodeFlag_exp_en >
129+ * <GRIB2_CodeFlag_exp_en >
125130 * <No>2</No>
126131 * <Title_en>Code table 0.0 - Discipline of processed data in the GRIB message, number of GRIB Master table</Title_en>
127132 * <CodeFlag>1</CodeFlag>
128133 * <MeaningParameterDescription_en>Hydrological products</MeaningParameterDescription_en>
129134 * <Status>Operational</Status>
130- * </GRIB2_22_0_0_CodeFlag_exp_en >
135+ * </GRIB2_CodeFlag_exp_en >
131136 *
132137 * FlagTable:
133- * <GRIB2_22_0_0_CodeFlag_exp_en >
138+ * <GRIB2_CodeFlag_exp_en >
134139 * <No>168</No>
135140 * <Title_en>Flag table 3.4 - Scanning mode</Title_en>
136141 * <CodeFlag>1</CodeFlag>
137142 * <Value>0</Value>
138143 * <MeaningParameterDescription_en>Points of first row or column scan in the +i (+x)
139144 * direction</MeaningParameterDescription_en>
140145 * <Status>Operational</Status>
141- * </GRIB2_22_0_0_CodeFlag_exp_en >
142- * <GRIB2_22_0_0_CodeFlag_exp_en >
146+ * </GRIB2_CodeFlag_exp_en >
147+ * <GRIB2_CodeFlag_exp_en >
143148 * <No>169</No>
144149 * <Title_en>Flag table 3.4 - Scanning mode</Title_en>
145150 * <CodeFlag>1</CodeFlag>
146151 * <Value>1</Value>
147152 * <MeaningParameterDescription_en>Points of first row or column scan in the -i (-x)
148153 * direction</MeaningParameterDescription_en>
149154 * <Status>Operational</Status>
150- * </GRIB2_22_0_0_CodeFlag_exp_en >
155+ * </GRIB2_CodeFlag_exp_en >
151156 */
152157
153158 private void readGribCodes (Version version ) throws IOException {
@@ -175,8 +180,8 @@ private void readGribCodes(Version version) throws IOException {
175180 Map <String , WmoTable > map = new HashMap <>();
176181
177182 List <Element > featList = root .getChildren (elems [0 ]); // main element
183+ int line = 0 ;
178184 for (Element elem : featList ) {
179- String line = elem .getChildTextNormalize ("No" );
180185 String tableName = elem .getChildTextNormalize (elems [1 ]); // Title_en
181186 Element subtableElem = elem .getChild (elems [2 ]); // "SubTitle_en"
182187
@@ -194,7 +199,7 @@ private void readGribCodes(Version version) throws IOException {
194199 continue ;
195200 }
196201
197- if (subtableElem != null ) {
202+ if (subtableElem != null && ! subtableElem . getTextNormalize (). isEmpty () ) {
198203 tableName = subtableElem .getTextNormalize ();
199204 }
200205
@@ -212,6 +217,7 @@ private void readGribCodes(Version version) throws IOException {
212217 String status = (statusElem == null ) ? null : statusElem .getTextNormalize ();
213218
214219 wmoTable .addEntry (line , code , value , meaning , unit , status );
220+ line ++;
215221 }
216222 ios .close ();
217223
@@ -283,7 +289,7 @@ private WmoTable(String name, TableType type) {
283289 }
284290 }
285291
286- private WmoEntry addEntry (String line , String code , String value , String meaning , String unit , String status ) {
292+ private WmoEntry addEntry (int line , String code , String value , String meaning , String unit , String status ) {
287293 WmoEntry entry = new WmoEntry (line , code , value , meaning , unit , status );
288294 boolean isRange = (entry .start != entry .stop );
289295 if (!isRange ) {
@@ -327,8 +333,8 @@ public class WmoEntry {
327333 private final int number , value ;
328334 private final String code , meaning , name , unit , status ;
329335
330- WmoEntry (String line , String code , String valueS , String meaning , String unit , String status ) {
331- this .line = Integer . parseInt ( line ) ;
336+ WmoEntry (int line , String code , String valueS , String meaning , String unit , String status ) {
337+ this .line = line ;
332338 this .code = code ;
333339 this .meaning = meaning ;
334340 this .status = status ;
0 commit comments