From 54c7ec801a393349783dd89fa92b66113e46feb3 Mon Sep 17 00:00:00 2001 From: Mickaƫl Boiziot Date: Mon, 18 Nov 2019 10:10:17 +0100 Subject: [PATCH] Allow to parse floatComplex and doubleComplex datatype --- src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+), 0 deletions(-) diff --git a/src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java b/src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java index 91609e9..8e79a7c 100644 --- a/src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java +++ b/src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java @@ -281,6 +281,42 @@ public final class BinaryStreamParser implements DataParser { } else { dataBlock = stream.getDouble(); } + } else if (dataType.equals(DataType.FLOAT_COMPLEX)) { + if (rowSize != blockSize) { + int nb = rowSize / blockSize; + if (nb == 0) { dataBlock = ""; } + else { + StringJoiner sj = new StringJoiner(" ", "", ""); + for (int i = 0; i < nb; i++) { + sj.add(String.valueOf(stream.getFloat())); + sj.add(String.valueOf(stream.getFloat())); + } + dataBlock = sj.toString(); + } + } else { + StringJoiner sj = new StringJoiner(" ", "", ""); + sj.add(String.valueOf(stream.getFloat())); + sj.add(String.valueOf(stream.getFloat())); + dataBlock = sj.toString(); + } + } else if (dataType.equals(DataType.DOUBLE_COMPLEX)) { + if (rowSize != blockSize) { + int nb = rowSize / blockSize; + if (nb == 0) { dataBlock = ""; } + else { + StringJoiner sj = new StringJoiner(" ", "", ""); + for (int i = 0; i < nb; i++) { + sj.add(String.valueOf(stream.getDouble())); + sj.add(String.valueOf(stream.getDouble())); + } + dataBlock = sj.toString(); + } + } else { + StringJoiner sj = new StringJoiner(" ", "", ""); + sj.add(String.valueOf(stream.getDouble())); + sj.add(String.valueOf(stream.getDouble())); + dataBlock = sj.toString(); + } } else { BinaryStreamParser.LOGGER.warning("Data type " + dataType + " is not supported."); dataBlock = null; -- libgit2 0.21.2