protected List<Coordinate> transformCoordinateList(List<Coordinate> coords, boolean area) {
    int minPoints = area ? 4 : 2;
    if (coords.size() <= minPoints) {
      return coords;
    }
    // make sure we include the first and last points even if they are closer than the simplification threshold
    List<Coordinate> result = new ArrayList<>();
    result.add(coords.getFirst());
    // for polygons, additionally keep at least 2 intermediate points even if they are below simplification threshold
    // to avoid collapse.
    subsimplify(coords, result, 0, coords.size() - 1, minPoints - 2);
    result.add(coords.getLast());
    return result;
  }
Returns the square of the number of units that (px, p1) is away from the line segment from (p1x, py1) to (p2x,
p2y).
planetiler-core/src/main/java/com/onthegomap/planetiler/geo/DouglasPeuckerSimplifier.java