Skip to content
Snippets Groups Projects
Commit d87c8be2 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

SpectrumStack overrides getBlockAt method for useMap case

parent b2beb349
Branches
Tags 1.54.0
No related merge requests found
...@@ -10,7 +10,9 @@ import org.cdma.interfaces.IKey; ...@@ -10,7 +10,9 @@ import org.cdma.interfaces.IKey;
import fr.soleil.cdma.box.reader.ICDMAReader; import fr.soleil.cdma.box.reader.ICDMAReader;
import fr.soleil.cdma.box.util.PositionKey; import fr.soleil.cdma.box.util.PositionKey;
import fr.soleil.lib.project.data.FlatData;
import fr.soleil.lib.project.math.ArrayUtils; import fr.soleil.lib.project.math.ArrayUtils;
import fr.soleil.lib.project.math.MathConst;
import fr.soleil.lib.project.math.NumberArrayUtils; import fr.soleil.lib.project.math.NumberArrayUtils;
/** /**
...@@ -227,6 +229,44 @@ public class SpectrumStack extends StackedData { ...@@ -227,6 +229,44 @@ public class SpectrumStack extends StackedData {
return result; return result;
} }
@Override
public FlatData getBlockAt(int nbOfData, int... position) {
FlatData result;
if (useMap) {
if ((nbOfData > 0) && (spectrumLength > 0) && (position != null) && (stackShape != null)
&& (position.length == stackShape.length)) {
int count = Math.min(nbOfData, stackShape[stackShape.length - 1] - position[position.length - 1]);
if (count > 0) {
double[] array = new double[count * spectrumLength];
Arrays.fill(array, MathConst.NAN_FOR_NULL);
int[] index = position.clone();
int i = 0;
while (ArrayUtils.isPosition(stackShape, index)) {
SoftIndexedData<double[]> data = spectra.get(new PositionKey(index));
if (data != null) {
double[] spectrum = data.getData();
if (spectrum != null) {
System.arraycopy(spectrum, 0, array, i * spectrumLength, spectrumLength);
}
}
ArrayUtils.incrementPosition(stackShape, index);
if (++i >= count) {
break;
}
}
result = new FlatData(new int[] { count, spectrumLength }, array);
} else {
result = null;
}
} else {
result = null;
}
} else {
result = super.getBlockAt(nbOfData, position);
}
return result;
}
// /** // /**
// * Recovers a slice in the full image stack (considered as a point stack), at a given position. // * Recovers a slice in the full image stack (considered as a point stack), at a given position.
// * // *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment