Class MBTilesTileDataSource

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

public class MBTilesTileDataSource extends TileDataSource
A tile data source that loads tiles from a local Sqlite database.
The database must contain table "tiles" with the following fields:
"zoom_level" (tile zoom level), "tile_column" (tile x coordinate),
"tile_row" (tile y coordinate), "tile_data" (compressed tile image).
  • Constructor Details

    • MBTilesTileDataSource

      public MBTilesTileDataSource(String path) throws IOException
      Constructs a MBTilesTileDataSource object. TMS tile scheme is used,
      Min and max zoom levels are automatically detected.
      Parameters:
      path - The path to the local Sqlite database file.
      Throws:
      Exception - If the the file could not be opened.
      IOException
    • MBTilesTileDataSource

      public MBTilesTileDataSource(int minZoom, int maxZoom, String path) throws IOException
      Constructs a MBTilesTileDataSource object. TMS tile scheme is used.
      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 local Sqlite database file.
      Throws:
      Exception - If the the file could not be opened.
      IOException
    • MBTilesTileDataSource

      public MBTilesTileDataSource(int minZoom, int maxZoom, String path, int scheme) throws IOException
      Constructs a MBTilesTileDataSource object with specified tile scheme.
      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 local Sqlite database file.
      scheme - Tile scheme to use.
      Throws:
      Exception - If the the file could not be opened.
      IOException
  • Method Details

    • getContainerMetaData

      public StringMap getContainerMetaData()
      Get data source metadata information.
      Possible parameters can be found in MBTiles specification.
      Returns:
      Map containing meta data information (parameter names mapped to parameter values).
    • getContainerMetaData

      public String getContainerMetaData(String key)
      Description copied from class: TileDataSource
      Reads one entry of the source's own metadata, when it has any - the MBTiles or PMTiles
      metadata table, for instance. Sources that carry none return an empty string, as do keys
      they do not define. Unlike the meta data map above this is read-only and is NOT attached
      to the loaded tiles: a container's metadata can be tens of kilobytes.
      Overrides:
      getContainerMetaData in class TileDataSource
      Parameters:
      key - The metadata key, as named by the container's specification.
      Returns:
      The value, or empty string if the source does not provide it.
    • 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.
    • getTileMask

      public String getTileMask()
    • 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.