Class CacheTileDataSource

java.lang.Object
com.massifmaps.datasources.TileDataSource
com.massifmaps.datasources.CacheTileDataSource
Direct Known Subclasses:
MemoryCacheTileDataSource, PersistentCacheTileDataSource

public class CacheTileDataSource extends TileDataSource
A tile data source that loads tiles from another tile data source and caches them.
  • Constructor Details

    • CacheTileDataSource

      protected CacheTileDataSource(TileDataSource dataSource)
  • Method Details

    • 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.
    • 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.
    • notifyTilesChanged

      public void notifyTilesChanged(boolean removeTiles)
      Description copied from class: TileDataSource
      Notifies listeners that the tiles have changed. Action taken depends on the implementation of the
      listeners, but generally all cached tiles will be reloaded. If the removeTiles flag is set all caches will be cleared
      prior to reloading, if it's not set then the reloaded tiles will replace the old tiles in caches as they finish loading.
      Overrides:
      notifyTilesChanged in class TileDataSource
      Parameters:
      removeTiles - The remove tiles flag.
    • getDataSource

      public TileDataSource getDataSource()
      Returns the original data source that the cache uses.
      Returns:
      The original data source.
    • clear

      public void clear()
      Clear the cache.
    • getCapacity

      public long getCapacity()
      Returns the tile cache capacity.
      Returns:
      The tile cache capacity in bytes.
    • setCapacity

      public void setCapacity(long capacityInBytes)
      Sets the cache capacity.
      Parameters:
      capacityInBytes - The new tile cache capacity in bytes.