### Question:
PointReducer { public static ArrayList<GeoPoint> reduceWithTolerance(ArrayList<GeoPoint> shape, double tolerance) { int n = shape.size(); if (tolerance <= 0 || n < 3) { return shape; } boolean [] marked = new boolean[n]; for (int i=1; i<n-1; i++) marked[i] = false; marked[0] = marked[n-1] = true; douglasPeuckerReduction( shape, marked, tolerance, 0, n-1 ); ArrayList<GeoPoint> newShape = new ArrayList<GeoPoint>(n); for (int i=0; i<n; i++){ if (marked[i]) newShape.add(shape.get(i)); } return newShape; }  static ArrayList<GeoPoint> reduceWithTolerance(ArrayList<GeoPoint> shape, double tolerance); static double orthogonalDistance(GeoPoint point, GeoPoint lineStart, GeoPoint lineEnd);  }### Answer:
@Test public void testReducer(){ ArrayList<GeoPoint> pts =new ArrayList<>(); pts.add(new GeoPoint(45, -74.0)); pts.add(new GeoPoint(45.0009, -74.0009)); pts.add(new GeoPoint(45.0018, -74.0018)); ArrayList<GeoPoint> geoPoints = PointReducer.reduceWithTolerance(pts, 0.5 / 312); Assert.assertTrue(!geoPoints.isEmpty()); Assert.assertTrue(geoPoints.size()+"", geoPoints.size()==2); }