PolylineUtils { @NonNull public static List<Point> simplify(@NonNull List<Point> points) { return simplify(points, SIMPLIFY_DEFAULT_TOLERANCE, SIMPLIFY_DEFAULT_HIGHEST_QUALITY); } private  PolylineUtils(); @NonNull static List<Point> decode(@NonNull final String encodedPath, int precision); @NonNull static String encode(@NonNull final List<Point> path, int precision); @NonNull static List<Point> simplify(@NonNull List<Point> points); @NonNull static List<Point> simplify(@NonNull List<Point> points, double tolerance); @NonNull static List<Point> simplify(@NonNull List<Point> points, boolean highestQuality); @NonNull static List<Point> simplify(@NonNull List<Point> points, double tolerance,
                                     boolean highestQuality);  }
@Test public void simplify_neverReturnsNullButRatherAnEmptyList() throws Exception { List<Point> simplifiedPath = simplify(new ArrayList<Point>(), PRECISION_6); assertNotNull(simplifiedPath); }
@Test public void simplify_returnSameListWhenListSizeIsLessThanOrEqualToTwo(){ final List<Point> path = new ArrayList<>(); path.add(Point.fromLngLat(0, 0)); path.add(Point.fromLngLat(10, 0)); List<Point> simplifiedPath = simplify(path, PRECISION_6, true); assertTrue("Returned list is different from input list", path == simplifiedPath); }
@Test public void simplify_withHighestQuality() throws IOException{ List<Point> path = createPointListFromResourceFile(SIMPLIFICATION_INPUT); List<Point> simplifiedPath = simplify(path, PRECISION_5, true); List<Point> expectedSimplifiedPath = createPointListFromResourceFile(SIMPLIFICATION_EXPECTED_OUTPUT); assertTrue("Wrong number of points retained",simplifiedPath.size() == expectedSimplifiedPath.size()); int counter = 0; for(Point retainedPoint:simplifiedPath){ Point expectedPoint = expectedSimplifiedPath.get(counter); assertTrue("Wrong point retained by simplification algorithm",retainedPoint.equals(expectedPoint)); ++counter; } }