private void squashVertex(MutableCoordinateSequence result, double x1, double y1, double x2, double y2, double x3,
    double y3) {

    if (skipVertex(x1, y1, x2, y2, x3, y3)) {
      result.addPoint(x2, y2);
      return;
    }

    double nextB = b;
    double nextA = a;

    // check the amount of error introduced by removing this vertex (either by offset or area)
    // and if it is too large, then move nextA/nextB ratios closer to the vertex to limit the error
    if (maxVertexArea > 0 || maxSquaredVertexOffset > 0) {
      double magA = Math.hypot(x2 - x1, y2 - y1);
      double magB = Math.hypot(x3 - x2, y3 - y2);
      double den = magA * magB;
      double aDist = magA * (1 - b);
      double bDist = magB * a;
      double maxDistSquared = Double.POSITIVE_INFINITY;
      if (maxVertexArea > 0) {
        double sin = den <= 0 ? 0 : Math.abs(((x1 - x2) * (y3 - y2)) - ((y1 - y2) * (x3 - x2))) / den;
        if (sin != 0) {
          maxDistSquared = 2 * maxVertexArea / sin;
        }
      }
      if (maxSquaredVertexOffset > 0) {
        double cos = den <= 0 ? 0 : Math.clamp(((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2)) / den, -1, 1);
        maxDistSquared = Math.min(maxDistSquared, 2 * maxSquaredVertexOffset / (1 + cos));
      }
      double maxDist = Double.NaN;
      if (aDist * aDist > maxDistSquared) {
        nextB = 1 - (maxDist = Math.sqrt(maxDistSquared)) / magA;
      }
      if (bDist * bDist > maxDistSquared) {
        if (Double.isNaN(maxDist)) {
          maxDist = Math.sqrt(maxDistSquared);
        }
        nextA = maxDist / magB;
      }
    }

    result.addPoint(x1 + (x2 - x1) * nextB, y1 + (y2 - y1) * nextB);
    result.addPoint(x2 + (x3 - x2) * nextA, y2 + (y3 - y2) * nextA);
  }
Sets the maximum number of times that smoothing runs.
planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DualMidpointSmoother.java