@Test @Category(UnitTest.class) public void testIntWithZero() { int nodata = -9999; int result; Aggregator agg = new SumAggregator(); int[] values = {0, -9999, 3, 4}; result = agg.aggregate(values, nodata); assertEquals(7, result); int[] values2 = {0, -9999, 0, -9999}; result = agg.aggregate(values2, nodata); assertEquals(0, result); }
@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; }
SumAggregator 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; } }
SumAggregator 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; }  }
SumAggregator 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; }  @Override double aggregate(double[] values, double nodata); @Override float aggregate(float[] values, float nodata); @Override byte aggregate(byte[] values, byte nodata); @Override short aggregate(short[] values, short nodata); @Override int aggregate(int[] values, int 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); }
SumAggregator 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; }  @Override double aggregate(double[] values, double nodata); @Override float aggregate(float[] values, float nodata); @Override byte aggregate(byte[] values, byte nodata); @Override short aggregate(short[] values, short nodata); @Override int aggregate(int[] values, int 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);  }