@Override
  protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) {
    boolean area = parent instanceof LinearRing;
    if (coords.size() <= 2) {
      return coords.copy();
    }
    for (int iter = 0; iter < iters; iter++) {
      assert iter < iters - 1 || (minSquaredVertexOffset == 0 && minVertexArea == 0) : "reached max iterations";
      MutableCoordinateSequence result = new MutableCoordinateSequence();
      int last = coords.size() - 1;
      double x1, y1;
      double x2 = coords.getX(0), y2 = coords.getY(0);
      double x3 = coords.getX(1), y3 = coords.getY(1);
      // for lines, always add the first point but for polygons this is a placeholder that will be updated
      // when last vertex is squashed
      result.addPoint(x2, y2);
      for (int i = 1; i < last; i++) {
        x1 = x2;
        y1 = y2;
        x2 = x3;
        y2 = y3;
        x3 = coords.getX(i + 1);
        y3 = coords.getY(i + 1);
        squashVertex(result, x1, y1, x2, y2, x3, y3);
      }
      if (area) {
        squashVertex(result,
          coords.getX(last - 1),
          coords.getY(last - 1),
          coords.getX(0),
          coords.getY(0),
          coords.getX(1),
          coords.getY(1)
        );
        int idx = result.size() - 1;
        result.setX(0, result.getX(idx));
        result.setY(0, result.getY(idx));
      } else {
        result.addPoint(coords.getX(last), coords.getY(last));
      }
      // early exit case: if no vertices were collapsed then we are done smoothing
      if (coords.size() == result.size()) {
        return result;
      }
      coords = result;
    }
    return coords;
  }
Sets the maximum number of times that smoothing runs.
planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DualMidpointSmoother.java