/** Filter coplanar points. * @param noIdenticalPoints with input list of points * @param leniencyValue is the allowed distance of a point from the plane for cleanup of overly detailed polygons * @return the filtered list, or null if we can't get a legit polygon from the input. */ static List<GeoPoint> filterEdges(final List<GeoPoint> noIdenticalPoints, final double leniencyValue) { // Now, do the search needed to find a path that has no coplanarities in it. // It is important to check coplanarities using the points that are further away so the // plane is more precise. for (int i = 0; i < noIdenticalPoints.size(); i++) { //Search starting for current index. final SafePath resultPath = findSafePath(noIdenticalPoints, i, leniencyValue); if (resultPath != null && resultPath.previous != null) { // Read out result, maintaining ordering final List<GeoPoint> rval = new ArrayList<>(noIdenticalPoints.size()); resultPath.fillInList(rval); return rval; } } // No path found. This means that everything was coplanar. return null; }