PpeOp extends Operator { static Double getMedian(double[] listDoubles) { Arrays.sort(listDoubles); if (listDoubles[1] == 0) { return (listDoubles[3]); } else if (listDoubles[0] == 0) { return ((listDoubles[2] + listDoubles[3]) / 2); } else { return (listDoubles[2]); } }  @Override void initialize(); @Override void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm);  }
@Test public void testGetMedian() { double[] list = new double[]{1, 2, 1, 1, 1}; assertEquals(1, PpeOp.getMedian(list), 1e-10); double[] list2 = new double[]{0, 0, 1, 4, 2}; assertEquals(2, PpeOp.getMedian(list2), 1e-10); double[] list3 = new double[]{5, 4, 3, 2, 0}; assertEquals(3.5, PpeOp.getMedian(list3), 1e-10); }