@Test @Category(UnitTest.class) public void testInt() { int[] values = {1, 2, 3, 4}; int nodata = -9999; int result; Aggregator agg = new MeanAggregator(); result = agg.aggregate(values, nodata); assertEquals(2, result, epsilon); values[0] = nodata; result = agg.aggregate(values, nodata); assertEquals(3, result, epsilon); values[1] = nodata; result = agg.aggregate(values, nodata); assertEquals(3, result, epsilon); values[2] = nodata; result = agg.aggregate(values, nodata); assertEquals(4, result, epsilon); values[3] = nodata; result = agg.aggregate(values, nodata); assertEquals(nodata, result, epsilon); }
@Override public double aggregate(double[] values, double nodata) { double sum = 0; int count = 0; for (double value : values) { if (FloatUtils.isNotNodata(value, nodata)) { sum += value; count++; } } return (count == 0) ? nodata : (sum / count); }
MeanAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { double sum = 0; int count = 0; for (double value : values) { if (FloatUtils.isNotNodata(value, nodata)) { sum += value; count++; } } return (count == 0) ? nodata : (sum / count); } }
MeanAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { double sum = 0; int count = 0; for (double value : values) { if (FloatUtils.isNotNodata(value, nodata)) { sum += value; count++; } } return (count == 0) ? nodata : (sum / count); }  }
MeanAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { double sum = 0; int count = 0; for (double value : values) { if (FloatUtils.isNotNodata(value, nodata)) { sum += value; count++; } } return (count == 0) ? nodata : (sum / count); }  @Override double aggregate(double[] values, double nodata); @Override double aggregate(double[][] values, double weightx, double weighty,
    double nodata); @Override float aggregate(float[] values, float nodata); @Override float aggregate(float[][] values, double weightx, double weighty,
    float nodata); @Override int aggregate(int[] values, int nodata); @Override int aggregate(int[][] values, double weightx, double weighty,
    int nodata); @Override short aggregate(short[] values, short nodata); @Override short aggregate(short[][] values, double weightx, double weighty,
    short nodata); @Override byte aggregate(byte[] values, byte nodata); @Override byte aggregate(byte[][] values, double weightx, double weighty,
    byte nodata); }
MeanAggregator implements Aggregator { @Override public double aggregate(double[] values, double nodata) { double sum = 0; int count = 0; for (double value : values) { if (FloatUtils.isNotNodata(value, nodata)) { sum += value; count++; } } return (count == 0) ? nodata : (sum / count); }  @Override double aggregate(double[] values, double nodata); @Override double aggregate(double[][] values, double weightx, double weighty,
    double nodata); @Override float aggregate(float[] values, float nodata); @Override float aggregate(float[][] values, double weightx, double weighty,
    float nodata); @Override int aggregate(int[] values, int nodata); @Override int aggregate(int[][] values, double weightx, double weighty,
    int nodata); @Override short aggregate(short[] values, short nodata); @Override short aggregate(short[][] values, double weightx, double weighty,
    short nodata); @Override byte aggregate(byte[] values, byte nodata); @Override byte aggregate(byte[][] values, double weightx, double weighty,
    byte nodata);  }