if (values instanceof byte[]) { if (unsigned) { result = computeRangeUByte((byte[]) values, validator, range, pm); } else { result = computeRangeByte((byte[]) values, validator, range, pm); result = computeRangeUShort((short[]) values, validator, range, pm); } else { result = computeRangeShort((short[]) values, validator, range, pm); result = computeRangeUInt((int[]) values, validator, range, pm); } else { result = computeRangeInt((int[]) values, validator, range, pm); result = computeRangeFloat((float[]) values, validator, range, pm); } else if (values instanceof double[]) { result = computeRangeDouble((double[]) values, validator, range, pm); } else if (values instanceof DoubleList) { result = computeRangeDouble((DoubleList) values, validator, range, pm); } else if (values == null) { throw new IllegalArgumentException("values is null");
static Range createRangeFromArray(int[] rangeArray) { if (rangeArray != null && rangeArray.length >= 2) { final Range range = new Range(); range.setMin(rangeArray[0] < rangeArray[1] ? rangeArray[0] : rangeArray[1]); range.setMax(rangeArray[0] > rangeArray[1] ? rangeArray[0] : rangeArray[1]); return range; } return null; }
/** * Determines the angular discontinuity of the given tie point values. * * @return the angular discontinuity, will always be either {@link #DISCONT_AT_180} or * {@link #DISCONT_AT_360} */ public static int getDiscontinuity(float[] tiePoints) { final Range range = Range.computeRangeFloat(tiePoints, IndexValidator.TRUE, null, ProgressMonitor.NULL); if (range.getMax() > 180.0) { return DISCONT_AT_360; } else { return DISCONT_AT_180; } }
public void testAggregatingRangeByte() { final boolean unsigned = false; final byte[] bytes = new byte[]{2, -5, 7, 20, 40, 100}; final Range range = new Range(6, 15); range.aggregate(bytes, unsigned, IndexValidator.TRUE, ProgressMonitor.NULL); assertEquals(-5, range.getMin(), 1e-10); assertEquals(100, range.getMax(), 1e-10); range.setMinMax(6, 15); range.aggregate(bytes, unsigned, _validator, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10); assertEquals(40, range.getMax(), 1e-10); }
public void testComputeRangeGenericByte() { final boolean unsigned = false; byte[] bytes = new byte[]{2, -3, 4, 5, -6, 7, 8, 9}; Range range = new Range(); Range.computeRangeGeneric(bytes, unsigned, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(9, range.getMax(), 1e-10d); Range.computeRangeGeneric(bytes, unsigned, _validator, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(7, range.getMax(), 1e-10d); }
public void testComputeRangeDouble() { double[] doubles = new double[]{2, -3, 4, 5, -6, 7, 8, 9}; Range range = new Range(); Range.computeRangeDouble(doubles, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(9, range.getMax(), 1e-10d); Range.computeRangeDouble(doubles, _validator, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(7, range.getMax(), 1e-10d); }
public void testComputeRangeFloat() { float[] floats = new float[]{2, -3, 4, 5, -6, 7, 8, 9}; Range range = new Range(); Range.computeRangeFloat(floats, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(9, range.getMax(), 1e-10d); Range.computeRangeFloat(floats, _validator, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(7, range.getMax(), 1e-10d); }
public void aggregate(final Object values, boolean unsigned, final IndexValidator validator, ProgressMonitor pm) { Guardian.assertNotNull("validator", validator); final Range range = computeRangeGeneric(values, unsigned, validator, null, pm); setMax(Math.max(getMax(), range.getMax())); setMin(Math.min(getMin(), range.getMin())); }
public void testComputeRangeInt() { int[] ints = new int[]{2, -3, 4, 5, -6, 7, 8, 9}; Range range = new Range(); Range.computeRangeInt(ints, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(9, range.getMax(), 1e-10d); Range.computeRangeInt(ints, _validator, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(7, range.getMax(), 1e-10d); }
public void testComputeRangeByte() { byte[] bytes = new byte[]{2, -3, 4, 5, -6, 7, 8, 9}; Range range = new Range(); Range.computeRangeByte(bytes, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(9, range.getMax(), 1e-10d); Range.computeRangeByte(bytes, _validator, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(7, range.getMax(), 1e-10d); }
public void testComputeRangeShort() { short[] shorts = new short[]{2, -3, 4, 5, -6, 7, 8, 9}; Range range = new Range(); Range.computeRangeShort(shorts, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(9, range.getMax(), 1e-10d); Range.computeRangeShort(shorts, _validator, range, ProgressMonitor.NULL); assertEquals(-6, range.getMin(), 1e-10d); assertEquals(7, range.getMax(), 1e-10d); }
public void testComputeRangeUShort() { final short[] uShorts = TestHelper.createUShorts(new int[]{2, 65533, 4, 5, 65530, 7, 8, 9}); Range range = new Range(); Range.computeRangeUShort(uShorts, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(65533, range.getMax(), 1e-10d); Range.computeRangeUShort(uShorts, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(65530, range.getMax(), 1e-10d); }
public void testComputeRangeUInt() { final int[] uInts = TestHelper.createUInts(new long[]{2, 4294967293L, 4, 5, 4294967290L, 7, 8, 9}); Range range = new Range(); Range.computeRangeUInt(uInts, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(4294967293L, range.getMax(), 1e-10d); Range.computeRangeUInt(uInts, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(4294967290L, range.getMax(), 1e-10d); }
public void testComputeRangeUByte() { final byte[] uBytes = TestHelper.createUBytes(new short[]{2, 253, 4, 5, 250, 7, 8, 9}); Range range = new Range(); try { Range.computeRangeUByte(uBytes, null, range, ProgressMonitor.NULL); fail("IllegalArgumentException expected because validator is null."); } catch (Exception expected) { } Range.computeRangeUByte(uBytes, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(253, range.getMax(), 1e-10d); Range.computeRangeUByte(uBytes, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(250, range.getMax(), 1e-10d); }
private GeoCoding createStripeGeocode(float[] lats, float[] lons, int y, int stripeW, int stripeH) throws IOException { final Range range = Range.computeRangeFloat(lats, IndexValidator.TRUE, null, ProgressMonitor.NULL); if (range.getMin() < -90) { return null; } else { final BowtiePixelScanGeoCoding geoCoding = new BowtiePixelScanGeoCoding(lats, lons, stripeW, stripeH); _cross180 = _cross180 || geoCoding.isCrossingMeridianAt180(); return geoCoding; } }
@Override public double getYMin() { return energyRange.getMin(); }
private static Range getValueRange(int dataType) { Range range = new Range(); switch (dataType) { case ProductData.TYPE_INT8: range.setMinMax(Byte.MIN_VALUE, Byte.MAX_VALUE); break; case ProductData.TYPE_INT16: range.setMinMax(Short.MIN_VALUE, Short.MAX_VALUE); break; case ProductData.TYPE_INT32: range.setMinMax(Integer.MIN_VALUE, Integer.MAX_VALUE); break; case ProductData.TYPE_UINT8: range.setMinMax(0, Math.pow(2, 8) - 1); break; case ProductData.TYPE_UINT16: range.setMinMax(0, Math.pow(2, 16) - 1); break; case ProductData.TYPE_UINT32: range.setMinMax(0, Math.pow(2, 32) - 1); break; case ProductData.TYPE_FLOAT32: range.setMinMax(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY); break; case ProductData.TYPE_FLOAT64: range.setMinMax(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); break; default: