private static void addPolygonRings(List<Ring> polygons, Geometry geom) {
    if (geom instanceof Polygon poly) {
      polygons.add(new Ring(poly));
    } else if (geom instanceof GeometryCollection geometryCollection) {
      for (int i = 0; i < geom.getNumGeometries(); i++) {
        addPolygonRings(polygons, geometryCollection.getGeometryN(i));
      }
    }
  }
Builds a multipolygon from linestrings containing the IDs of nodes in edge segments and a node ID location
provider.
<p>
Attempts to close rings where endpoints are within {@code minGap} units apart.

@param rings     edge segment node ID sequences
@param nodeCache node location provider
@param osmId     ID of this multipolygon
@param minGap    the minimum units apart to close a linestring
@return The new multipolygon
@throws GeometryException if building the polygon fails
planetiler-core/src/main/java/com/onthegomap/planetiler/reader/osm/OsmMultipolygon.java