### Question:
DouglasPeucker { static void removeNaN(PointList pointList) { int curr = 0; for (int i = 0; i < pointList.size(); i++) { if (!Double.isNaN(pointList.getLatitude(i))) { pointList.set(curr, pointList.getLatitude(i), pointList.getLongitude(i), pointList.getElevation(i)); curr++; } } pointList.trimToSize(curr); } DouglasPeucker(); void setApproximation(boolean a); DouglasPeucker setMaxDistance(double dist); int simplify(PointList points); int simplify(PointList points, int fromIndex, int lastIndex); int simplify(PointList points, int fromIndex, int lastIndex, boolean compress);  }### Answer:
@Test public void testRemoveNaN() { PointList pl = new PointList(10, true); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(1, 1, 1); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(5, 5, 5); pl.add(6, 6, 6); pl.add(7, 7, 7); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(8, 8, 8); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(9, 9, 9); pl.add(10, 10, 10); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(Double.NaN, Double.NaN, Double.NaN); pl.add(14, 14, 14); pl.add(Double.NaN, Double.NaN, Double.NaN); DouglasPeucker.removeNaN(pl); DouglasPeucker.removeNaN(pl); DouglasPeucker.removeNaN(pl); assertEquals(8, pl.size()); List<Integer> expected = Arrays.asList(1, 5, 6, 7, 8, 9, 10, 14); List<Integer> given = new ArrayList<>(); for (int i = 0; i < pl.size(); i++) { assertEquals(pl.getLat(i), pl.getEle(i), 1.e-6); assertEquals(pl.getLon(i), pl.getEle(i), 1.e-6); given.add((int) pl.getLat(i)); } assertEquals(expected, given); }