private static List<Ring> getClosedRings(OsmReader.NodeLocationProvider nodeCache, double minGap, boolean fix,
    List<LongArrayList> idSegments) throws GeometryException {
    List<Ring> polygons = new ArrayList<>(idSegments.size());
    for (LongArrayList segment : idSegments) {
      int size = segment.size();
      long firstId = segment.get(0), lastId = segment.get(size - 1);
      if (firstId == lastId || tryClose(segment, nodeCache, minGap)) {
        CoordinateSequence coordinates = nodeCache.getWayGeometry(segment);
        Polygon poly = GeoUtils.JTS_FACTORY.createPolygon(coordinates);
        // the first time through, just process the polygon
        // if that fails, then the second time attempt to repair the geometry before processing
        Geometry fixed = fix ? GeoUtils.fixPolygon(poly) : poly;
        addPolygonRings(polygons, fixed);
      }
    }
    return polygons;
  }
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