This is an automated email from the ASF dual-hosted git repository.

jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new e9389778e3 Fix beamFlags and qualityFlags in GSF decoder
e9389778e3 is described below

commit e9389778e3ef3291a98fe7b713fa584c3773b489
Author: jsorel <johann.so...@geomatys.com>
AuthorDate: Mon Nov 18 16:01:30 2024 +0100

    Fix beamFlags and qualityFlags in GSF decoder
---
 .../main/org/apache/sis/storage/gsf/StructClass.java           | 10 ++++++++++
 .../main/org/apache/sis/storage/gsf/SwathBathyPing.java        |  8 ++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/StructClass.java
 
b/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/StructClass.java
index 5fe1a5a952..d923fdd034 100644
--- 
a/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/StructClass.java
+++ 
b/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/StructClass.java
@@ -113,6 +113,16 @@ public abstract class StructClass {
         return dst;
     }
 
+    static int[] getUBytes(MemorySegment segment, int offset, int nb) {
+        if (segment.address() == 0L) return null; //C null adress
+        final ByteBuffer db = segment.asSlice(offset, nb).asByteBuffer();
+        final byte[] dst = new byte[nb];
+        db.get(0, dst);
+        final int[] uchar = new int[nb];
+        for (int i = 0; i < uchar.length;i++) uchar[i] = dst[i] & 0xFF;
+        return uchar;
+    }
+
     protected final short[] getShorts(int offset, int nb) {
         return getShorts(struct, offset, nb);
     }
diff --git 
a/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/SwathBathyPing.java
 
b/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/SwathBathyPing.java
index e4be45ec1b..84f9cb3a74 100644
--- 
a/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/SwathBathyPing.java
+++ 
b/incubator/src/org.apache.sis.storage.gsf/main/org/apache/sis/storage/gsf/SwathBathyPing.java
@@ -273,12 +273,12 @@ public final class SwathBathyPing extends StructClass {
         return getDoubles(struct.get(LAYOUT_ALONG_TRACK_ERROR, 960), 0, 
getNumberBeams());
     }
 
-    public double[] getQualityFlags() {
-        return getDoubles(struct.get(LAYOUT_QUALITY_FLAGS, 968), 0, 
getNumberBeams());
+    public int[] getQualityFlags() {
+        return getUBytes(struct.get(LAYOUT_QUALITY_FLAGS, 968), 0, 
getNumberBeams());
     }
 
-    public double[] getBeamFlags() {
-        return getDoubles(struct.get(LAYOUT_BEAM_FLAGS, 976), 0, 
getNumberBeams());
+    public int[] getBeamFlags() {
+        return getUBytes(struct.get(LAYOUT_BEAM_FLAGS, 976), 0, 
getNumberBeams());
     }
 
     public double[] getSignalToNoise() {

Reply via email to