diff --git a/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java b/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java index 2749a67..e4526db 100644 --- a/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java +++ b/src/main/java/org/matsim/analysis/postAnalysis/NoiseAverageAnalysis.java @@ -4,9 +4,9 @@ import org.apache.avro.file.DataFileReader; import org.apache.avro.file.DataFileWriter; import org.apache.avro.file.FileReader; -import org.apache.avro.generic.GenericData; import org.apache.avro.generic.GenericDatumReader; import org.apache.avro.generic.GenericRecord; +import org.apache.avro.generic.PrimitivesArrays; import org.apache.avro.io.DatumWriter; import org.apache.avro.specific.SpecificDatumWriter; import org.apache.avro.util.Utf8; @@ -215,10 +215,8 @@ private XYTData calcAvroMeans(List recordList, String dataFieldNa getCoordData(object1, xCoords); getCoordData(object2, yCoords); - -// TODO: for the example data even for the hourly data there was only one time stamp. This might be different with real data. this needs to be checked - if (object3 instanceof GenericData.Array) { - List ints = new ArrayList<>((GenericData.Array) object3); + if (object3 instanceof PrimitivesArrays.IntArray intArray) { + List ints = new ArrayList<>(intArray); if (!timeStamps.equals(ints)) { if (timeStamps.isEmpty()) { @@ -235,8 +233,8 @@ private XYTData calcAvroMeans(List recordList, String dataFieldNa List values = new ArrayList<>(); for (Map.Entry entry : ((HashMap) object4).entrySet()) { - if (entry.getKey() instanceof Utf8 && entry.getKey().toString().equals(dataFieldName) && entry.getValue() instanceof GenericData.Array) { - values.addAll((GenericData.Array) entry.getValue()); + if (entry.getKey() instanceof Utf8 && entry.getKey().toString().equals(dataFieldName) && entry.getValue() instanceof PrimitivesArrays.FloatArray floatArray) { + values.addAll(floatArray); String entryString = ((Utf8) entry.getKey()).toString(); @@ -265,8 +263,8 @@ private XYTData calcAvroMeans(List recordList, String dataFieldNa } private void getCoordData(Object object, List target) { - if (object instanceof GenericData.Array) { - List floats = new ArrayList<>((GenericData.Array) object); + if (object instanceof PrimitivesArrays.FloatArray floatArray) { + List floats = new ArrayList<>(floatArray); if (!target.equals(floats)) { if (target.isEmpty()) {