private static void extractPolygons(Geometry geom, List<Polygon> result, double minArea, double minHoleArea) {
    if (geom instanceof Polygon poly) {
      double outerArea = Area.ofRing(poly.getExteriorRing().getCoordinateSequence());
      if (outerArea > minArea) {
        int innerRings = poly.getNumInteriorRing();
        List<LinearRing> rings = innerRings == 0 ? List.of() : new ArrayList<>(innerRings);
        for (int i = 0; i < innerRings; i++) {
          LinearRing innerRing = poly.getInteriorRingN(i);
          if (minHoleArea <= 0 || Area.ofRing(innerRing.getCoordinateSequence()) > minArea) {
            rings.add(innerRing);
          }
        }
        LinearRing exteriorRing = poly.getExteriorRing();
        /* optimization: when merged polygon fill the entire tile, replace it with a canonical fill geometry to ensure
         * that filled tiles are byte-for-byte equivalent. This allows archives that deduplicate tiles to better compress
         * large filled areas like the ocean. */
        double fillBuffer = isFill(outerArea, exteriorRing);
        if (fillBuffer >= 0) {
          exteriorRing = createFill(fillBuffer);
        }
        if (rings.size() != innerRings || exteriorRing != poly.getExteriorRing()) {
          poly = GeoUtils.createPolygon(exteriorRing, rings);
        }
        result.add(poly);
      }
    } else if (geom instanceof GeometryCollection) {
      for (int i = 0; i < geom.getNumGeometries(); i++) {
        extractPolygons(geom.getGeometryN(i), result, minArea, minHoleArea);
      }
    }
  }
Puts all polygons within {@code geom} over {@code minArea} into {@code result}, removing holes under {@code
minHoleArea}.
planetiler-core/src/main/java/com/onthegomap/planetiler/FeatureMerge.java