/** * Returns the value as an <code>int</code>. <p>The method assumes that this value is a scalar and therefore simply * returns <code>getElemIntAt(0)</code>. * * @see #getElemIntAt(int index) */ public int getElemInt() { return getElemIntAt(0); }
/** * Gets the value element with the given index as a <code>boolean</code>. * * @param index the value index, must be <code>>=0</code> and <code><getNumDataElems()</code> * * @throws IndexOutOfBoundsException if the index is out of bounds */ public boolean getElemBooleanAt(int index) { return (getElemIntAt(index) != 0); }
@Override public final double evalD(final EvalEnv env) throws EvalException { final int elemIndex = ((RasterDataEvalEnv) env).getElemIndex(); return (data.getElemIntAt(elemIndex) & flagMask) == flagMask ? 1.0 : 0.0; } }
@Override public int evalI(final EvalEnv env) throws EvalException { final int elemIndex = ((RasterDataEvalEnv) env).getElemIndex(); return data.getElemIntAt(elemIndex); }
@Override public final boolean evalB(final EvalEnv env) throws EvalException { final int elemIndex = ((RasterDataEvalEnv) env).getElemIndex(); return (data.getElemIntAt(elemIndex) & flagMask) == flagMask; }
@Override public final int evalI(final EvalEnv env) throws EvalException { final int elemIndex = ((RasterDataEvalEnv) env).getElemIndex(); return (data.getElemIntAt(elemIndex) & flagMask) == flagMask ? 1 : 0; }
/** * Gets the field element with the given index as an <code>int</code>. * * @param index the field index, must be <code>>=0</code> and <code><getNumDataElems()</code> * * @throws java.lang.IndexOutOfBoundsException * if the index is out of bounds */ public int getElemInt(int index) { return getData().getElemIntAt(index); }
/** * Gets the <code>int</code> value of the parameter with the given key. The method performs a case-insensitive * search. * * @param key the parameter key * * @return the parameter value * * @throws HeaderEntryNotFoundException if an entry with the given key could not be found in the header */ public int getParamInt(String key, int elemIndex) throws HeaderEntryNotFoundException { return getParamImpl(key).getData().getElemIntAt(elemIndex); }
private void assert_a_times_b_is_c(ProductData r, int i, int x, int y) { int a = 2 * x + 4 * y; int b = 3 * x + 5 * y; int c = a * b; assertEquals("i=" + i, c, r.getElemIntAt(i)); }
private void assert_a_plus_b_plus_c_is_d(ProductData r, int i, int x, int y) { int a = 2 * x + 4 * y; int b = 3 * x + 5 * y; int c = a * b; int d = a + b + c; assertEquals("i=" + i, d, r.getElemIntAt(i)); }
public void testSetElemsAsString() { final ProductData pd = ProductData.createInstance(ProductData.TYPE_INT16, 3); pd.setElems(new String[]{ String.valueOf(Short.MAX_VALUE), String.valueOf(0), String.valueOf(Short.MIN_VALUE), }); assertEquals(Short.MAX_VALUE, pd.getElemIntAt(0)); assertEquals(0, pd.getElemIntAt(1)); assertEquals(Short.MIN_VALUE, pd.getElemIntAt(2)); }
public void testSetElemsAsString() { final ProductData pd = ProductData.createInstance(ProductData.TYPE_INT32, 3); pd.setElems(new String[]{ String.valueOf(Integer.MAX_VALUE), String.valueOf(Integer.MIN_VALUE), String.valueOf(0), }); assertEquals(Integer.MAX_VALUE, pd.getElemIntAt(0)); assertEquals(Integer.MIN_VALUE, pd.getElemIntAt(1)); assertEquals(0, pd.getElemIntAt(2)); }
public void testSetElemsAsString() { final ProductData pd = ProductData.createInstance(ProductData.TYPE_UINT8, 3); pd.setElems(new String[]{ String.valueOf(Byte.MAX_VALUE * 2 + 1), String.valueOf(Byte.MAX_VALUE), String.valueOf(0), }); assertEquals(Byte.MAX_VALUE * 2 + 1, pd.getElemIntAt(0)); assertEquals(Byte.MAX_VALUE, pd.getElemIntAt(1)); assertEquals(0, pd.getElemIntAt(2)); }
public void testSetElemsAsString() { final ProductData pd = ProductData.createInstance(ProductData.TYPE_UINT16, 3); pd.setElems(new String[]{ String.valueOf(Short.MAX_VALUE * 2 + 1), String.valueOf(Short.MAX_VALUE), String.valueOf(0), }); assertEquals(Short.MAX_VALUE * 2 + 1, pd.getElemIntAt(0)); assertEquals(Short.MAX_VALUE, pd.getElemIntAt(1)); assertEquals(0, pd.getElemIntAt(2)); }
public void testSetElemsAsString() { final ProductData pd = ProductData.createInstance(ProductData.TYPE_INT8, 3); pd.setElems(new String[]{ String.valueOf(Byte.MAX_VALUE), String.valueOf(Byte.MIN_VALUE), String.valueOf(0), }); assertEquals(Byte.MAX_VALUE, pd.getElemIntAt(0)); assertEquals(Byte.MIN_VALUE, pd.getElemIntAt(1)); assertEquals(0, pd.getElemIntAt(2)); }
private int getPixelsPerTiePoint() throws IOException { final RecordReader geoRecordReader = getRecordReader("GEOLOCATION_GRID_ADS"); if (geoRecordReader == null) { return 0; } final Record rec = geoRecordReader.readRecord(0); final Field sampNumberField = rec.getField("ASAR_Geo_Grid_ADSR.sd/first_line_tie_points.samp_numbers"); if (sampNumberField == null) { return 0; } return sampNumberField.getData().getElemIntAt(1) - 1; }
@Override public int getSampleInt(int x, int y) { int sample = dataBuffer.getElemIntAt(index(x, y)); // handle unsigned data types, see also [BEAM-1147] (nf - 20100527) if (signedByte) { //noinspection SillyAssignment sample = (byte) sample; } if (scaled) { sample = (int) Math.floor(toGeoPhysical(sample) + 0.5); } return sample; }
public void testSetElemsAsString() { final ProductData pd = ProductData.createInstance(ProductData.TYPE_UINT32, 3); pd.setElems(new String[]{ String.valueOf((long) Integer.MAX_VALUE * 2 + 1), String.valueOf(Integer.MAX_VALUE), String.valueOf(0), }); assertEquals((long) Integer.MAX_VALUE * 2 + 1, pd.getElemUIntAt(0)); assertEquals(-1, pd.getElemIntAt(0)); assertEquals(Integer.MAX_VALUE, pd.getElemUIntAt(1)); assertEquals(Integer.MAX_VALUE, pd.getElemIntAt(1)); assertEquals(0, pd.getElemIntAt(2)); }
/** * Gets the sample for the pixel located at (x,y) as an integer value. * * @param x The X co-ordinate of the pixel location * @param y The Y co-ordinate of the pixel location * @throws NullPointerException if this band has no raster data * @throws java.lang.ArrayIndexOutOfBoundsException * if the co-ordinates are not in bounds */ @Override public int getPixelInt(int x, int y) { if (isScalingApplied()) { return (int) Math.round(scale(getRasterData().getElemDoubleAt(getRasterWidth() * y + x))); } else { return getRasterData().getElemIntAt(getRasterWidth() * y + x); } }
if (scaled) { for (int i = 0; i < size; i++) { samples[i] = (int) toGeoPhysical(data.getElemIntAt(i)); samples[i] = data.getElemIntAt(i);