@Override
  public TileArchiveMetadata metadata() {

    TileCompression tileCompression = switch (header.tileCompression()) {
      case GZIP -> TileCompression.GZIP;
      case NONE -> TileCompression.NONE;
      case UNKNOWN -> TileCompression.UNKNOWN;
    };

    String format = switch (header.tileType()) {
      case MVT -> TileArchiveMetadata.MVT_FORMAT;
      default -> null;
    };

    try {
      var jsonMetadata = getJsonMetadata();
      var map = new LinkedHashMap<>(jsonMetadata.otherMetadata());
      return new TileArchiveMetadata(
        map.remove(TileArchiveMetadata.NAME_KEY),
        map.remove(TileArchiveMetadata.DESCRIPTION_KEY),
        map.remove(TileArchiveMetadata.ATTRIBUTION_KEY),
        map.remove(TileArchiveMetadata.VERSION_KEY),
        map.remove(TileArchiveMetadata.TYPE_KEY),
        format,
        header.bounds(),
        new Coordinate(
          header.center().getX(),
          header.center().getY(),
          header.centerZoom()
        ),
        (int) header.minZoom(),
        (int) header.maxZoom(),
        TileArchiveMetadata.TileArchiveMetadataJson.create(jsonMetadata.vectorLayers()),
        map,
        tileCompression
      );
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
  }
Finds the relevant entry for a tileId in a list of entries.
<p>
If there is an exact match for tileId, return that. Else if the tileId matches an entry's tileId + runLength,
return that. Else if the preceding entry is a directory (runLength = 0), return that. Else return null.
planetiler-core/src/main/java/com/onthegomap/planetiler/pmtiles/ReadablePmtiles.java