Class PMTilesTileDataSource

java.lang.Object
com.massifmaps.datasources.TileDataSource
com.massifmaps.datasources.PMTilesTileDataSource

public class PMTilesTileDataSource extends TileDataSource
A tile data source that loads tiles from a PMTiles v3 archive file.
PMTiles is a single-file archive format for pyramids of tiled data.
The archive format supports efficient random access and metadata storage.
  • Constructor Details

    • PMTilesTileDataSource

      public PMTilesTileDataSource(String path) throws IOException
      Constructs a PMTilesTileDataSource object.
      Min and max zoom levels are automatically detected from the PMTiles header.
      Parameters:
      path - The path to the PMTiles archive file.
      Throws:
      Exception - If the file could not be opened or is not a valid PMTiles archive.
      IOException
    • PMTilesTileDataSource

      public PMTilesTileDataSource(int minZoom, int maxZoom, String path) throws IOException
      Constructs a PMTilesTileDataSource object with specified zoom levels.
      Parameters:
      minZoom - The minimum zoom level supported by this data source.
      maxZoom - The maximum zoom level supported by this data source.
      path - The path to the PMTiles archive file.
      Throws:
      Exception - If the file could not be opened or is not a valid PMTiles archive.
      IOException
  • Method Details

    • getContainerMetaData

      public String getContainerMetaData()
      Get PMTiles archive metadata information as a JSON string.
      The metadata is stored in the PMTiles archive and may contain
      information such as name, description, attribution, vector layers, etc.
      Returns:
      JSON string containing metadata, or empty string if no metadata exists.
    • getContainerMetaData

      public String getContainerMetaData(String key)
      Get a specific metadata value by key from the parsed JSON metadata.
      Overrides:
      getContainerMetaData in class TileDataSource
      Parameters:
      key - The metadata key to retrieve (e.g., "name", "description", "attribution").
      Returns:
      The metadata value as a string, or empty string if not found.
    • getMinZoom

      public int getMinZoom()
      Description copied from class: TileDataSource
      Returns the minimum zoom level supported by this data source.
      Overrides:
      getMinZoom in class TileDataSource
      Returns:
      The minimum zoom level supported (inclusive).
    • getMaxZoom

      public int getMaxZoom()
      Description copied from class: TileDataSource
      Returns the maximum zoom level supported by this data source.
      Overrides:
      getMaxZoom in class TileDataSource
      Returns:
      The maximum zoom level supported (exclusive).
    • getDataExtent

      public MapBounds getDataExtent()
      Description copied from class: TileDataSource
      Returns the extent of the tiles in this data source.
      The bounds are in coordinate system of the projection of the data source.
      Overrides:
      getDataExtent in class TileDataSource
      Returns:
      The extent of the data source.
    • loadTile

      public TileData loadTile(MapTile mapTile)
      Description copied from class: TileDataSource
      Loads the specified tile.
      Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.
      Overrides:
      loadTile in class TileDataSource
      Parameters:
      mapTile - The tile to load.
      Returns:
      The tile data. If the tile is not available, null may be returned.