private void tileWriter(Iterable<TileBatch> tileBatches) throws ExecutionException, InterruptedException {

    final boolean firstTileWriter = firstTileWriterTracker.compareAndExchange(true, false);

    var f = NumberFormat.getNumberInstance(Locale.getDefault());
    f.setMaximumFractionDigits(5);

    var order = archive.tileOrder();

    TileCoord lastTile = null;
    Timer time = null;
    int currentZ = Integer.MIN_VALUE;
    try (var tileWriter = archive.newTileWriter()) {
      for (TileBatch batch : tileBatches) {
        for (var encodedTile : batch.out.get()) {
          TileCoord tileCoord = encodedTile.coord();
          assert lastTile == null ||
            order.encode(tileCoord) > order.encode(lastTile) : "Tiles out of order %s before %s"
              .formatted(lastTile, tileCoord);
          lastTile = encodedTile.coord();
          int z = tileCoord.z();
          if (z != currentZ) {
            // for multiple writers the starting/finish log message of the _first_ tilewriter
            // is not 100% accurate in terms of overall "zoom-progress",
            // but it should be a "good-enough" indicator for "zoom-progress"-logging
            if (firstTileWriter) {
              if (time == null) {
                LOGGER.info("Starting z{}", z);
              } else {
                LOGGER.info("Finished z{} in {}, now starting z{}", currentZ, time.stop(), z);
              }
            }
            time = Timer.start();
            currentZ = z;
          }
          tileWriter.write(encodedTile);

          stats.wroteTile(z, encodedTile.tileData().length);
          tilesByZoom[z].inc();
        }
        lastTileWritten.set(lastTile);
      }
      tileWriter.printStats();
    }

    if (time != null) {
      LOGGER.info("Finished z{} in {}", currentZ, time.stop());
    }
  }
Reads all {@code features}, encodes them in parallel, and writes to {@code output}.
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveWriter.java