@Test @Category(UnitTest.class) public void testFloat() { float[] values = {0.21f, 0.32f, 0.43f, 0.54f}; float nodata = -9999.0f; float result; Aggregator agg = new NearestAggregator(); result = agg.aggregate(values, nodata); assertEquals(0.21, result, epsilon); values[0] = nodata; result = agg.aggregate(values, nodata); assertEquals(0.32, result, epsilon); values[1] = nodata; result = agg.aggregate(values, nodata); assertEquals(0.54, result, epsilon); values[3] = nodata; result = agg.aggregate(values, nodata); assertEquals(0.43, result, epsilon); values[2] = nodata; result = agg.aggregate(values, nodata); assertEquals(nodata, result, epsilon); }
@Override public double aggregate(double[] values, double nodata) { boolean data0 = FloatUtils.isNotNodata(values[0], nodata); boolean data1 = FloatUtils.isNotNodata(values[1], nodata); boolean data2 = FloatUtils.isNotNodata(values[2], nodata); boolean data3 = FloatUtils.isNotNodata(values[3], nodata); if (data0) { return values[0]; } if (data1) { return values[1]; } if (data3) { return values[3]; } if (data2) { return values[2]; } return nodata; }
NearestAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { boolean data0 = FloatUtils.isNotNodata(values[0], nodata); boolean data1 = FloatUtils.isNotNodata(values[1], nodata); boolean data2 = FloatUtils.isNotNodata(values[2], nodata); boolean data3 = FloatUtils.isNotNodata(values[3], nodata); if (data0) { return values[0]; } if (data1) { return values[1]; } if (data3) { return values[3]; } if (data2) { return values[2]; } return nodata; } }
NearestAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { boolean data0 = FloatUtils.isNotNodata(values[0], nodata); boolean data1 = FloatUtils.isNotNodata(values[1], nodata); boolean data2 = FloatUtils.isNotNodata(values[2], nodata); boolean data3 = FloatUtils.isNotNodata(values[3], nodata); if (data0) { return values[0]; } if (data1) { return values[1]; } if (data3) { return values[3]; } if (data2) { return values[2]; } return nodata; }  }
NearestAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { boolean data0 = FloatUtils.isNotNodata(values[0], nodata); boolean data1 = FloatUtils.isNotNodata(values[1], nodata); boolean data2 = FloatUtils.isNotNodata(values[2], nodata); boolean data3 = FloatUtils.isNotNodata(values[3], nodata); if (data0) { return values[0]; } if (data1) { return values[1]; } if (data3) { return values[3]; } if (data2) { return values[2]; } return nodata; }  @Override double aggregate(double[] values, double nodata); @Override float aggregate(float[] values, float nodata); @Override int aggregate(int[] values, int nodata); @Override short aggregate(short[] values, short nodata); @Override byte aggregate(byte[] values, byte nodata); @Override double aggregate(double[][] values, double weightx, double weighty, double nodata); @Override float aggregate(float[][] values, double weightx, double weighty, float nodata); @Override byte aggregate(byte[][] values, double weightx, double weighty, byte nodata); @Override short aggregate(short[][] values, double weightx, double weighty, short nodata); @Override int aggregate(int[][] values, double weightx, double weighty, int nodata); }
NearestAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { boolean data0 = FloatUtils.isNotNodata(values[0], nodata); boolean data1 = FloatUtils.isNotNodata(values[1], nodata); boolean data2 = FloatUtils.isNotNodata(values[2], nodata); boolean data3 = FloatUtils.isNotNodata(values[3], nodata); if (data0) { return values[0]; } if (data1) { return values[1]; } if (data3) { return values[3]; } if (data2) { return values[2]; } return nodata; }  @Override double aggregate(double[] values, double nodata); @Override float aggregate(float[] values, float nodata); @Override int aggregate(int[] values, int nodata); @Override short aggregate(short[] values, short nodata); @Override byte aggregate(byte[] values, byte nodata); @Override double aggregate(double[][] values, double weightx, double weighty, double nodata); @Override float aggregate(float[][] values, double weightx, double weighty, float nodata); @Override byte aggregate(byte[][] values, double weightx, double weighty, byte nodata); @Override short aggregate(short[][] values, double weightx, double weighty, short nodata); @Override int aggregate(int[][] values, double weightx, double weighty, int nodata);  }