Skip to content

Commit 183c1dd

Browse files
committed
reflect ecCodes bugfix [ECC-1197] in version v2.21.0: headline extraction with spaces not commas
[ECC-1197] - grib_get_data: Words on the first line should be separated by spaces not commas see https://jira.ecmwf.int/browse/ECC-1197 for details
1 parent bd1a7c2 commit 183c1dd

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ext {
2323
}
2424

2525
group = 'com.github.ie3-institute'
26-
version = '0.4.5'
26+
version = '0.4.6'
2727
description = 'DWDWeatherTools'
2828
defaultTasks 'build'
2929
sourceCompatibility = javaVersion

src/main/java/edu/ie3/tools/Extractor.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,21 @@ public Extractor(
4242
formattedTimestep = Converter.getFormattedTimestep(file);
4343
}
4444

45+
private boolean validHeadline(String headlineString) {
46+
// since eccodes v2.21.0 the data extraction expects a headline w/o commas but with whitespaces
47+
// see ECC-1197 - https://jira.ecmwf.int/browse/ECC-1197
48+
String headline = "Latitude Longitude Value";
49+
String oldHeadline = "Latitude, Longitude, Value";
50+
51+
return headlineString != null
52+
&& (headlineString.trim().equals(headline) || headlineString.trim().equals(oldHeadline));
53+
}
54+
4555
protected HashMap<CoordinateModel, Double> parse(BufferedReader reader) throws IOException {
4656
HashMap<CoordinateModel, Double> coordinateToValue = new HashMap<>(720729);
4757
try {
4858
String line = reader.readLine();
49-
if (line == null || !line.trim().equals("Latitude, Longitude, Value")) {
59+
if (!validHeadline(line)) {
5060
throw new IOException("Unexpected start of file: " + line);
5161
}
5262
while ((line = reader.readLine()) != null) {

src/test/java/edu/ie3/tools/ExtractorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class ExtractorTest {
2929

30-
private static String resourcesPath =
30+
private static final String resourcesPath =
3131
System.getProperty("user.dir")
3232
+ File.separator
3333
+ "src"
@@ -36,7 +36,7 @@ public class ExtractorTest {
3636
+ File.separator
3737
+ "resources"
3838
+ File.separator;
39-
private static String extractorPath = resourcesPath + "extractorFiles";
39+
private static final String extractorPath = resourcesPath + "extractorFiles";
4040

4141
private final FileModel dummyFileModel = new FileModel(ZonedDateTime.now(), 1, Parameter.ASOB_S);
4242

0 commit comments

Comments
 (0)