Class TileDataSource

java.lang.Object
com.massifmaps.datasources.TileDataSource
Direct Known Subclasses:
AssetTileDataSource, BitmapOverlayRasterTileDataSource, CacheTileDataSource, CombinedTileDataSource, ContourTileDataSource, GeoJSONVectorTileDataSource, HTTPTileDataSource, MapTilerOnlineTileDataSource, MBTilesTileDataSource, MergedMBVTTileDataSource, MultiTileDataSource, OrderedTileDataSource, PackageManagerTileDataSource, PMTilesTileDataSource

public class TileDataSource extends Object
Abstract base class for tile data sources. It provides default implementation
for listener registration and other common tile data source methods.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs an abstract TileDataSource object.
    Note: EPSG3857 projection is used.
    protected
    TileDataSource(int minZoom, int maxZoom)
    Constructs an abstract TileDataSource object.
    Note: EPSG3857 projection is used.
  • Method Summary

    Modifier and Type
    Method
    Description
    Builds tag map from tile info.
    boolean
    Returns true if the specified key exists in the data source meta data map, or in the
    container's own metadata.
    Reads one entry of the source's own metadata, when it has any - the MBTiles or PMTiles
    metadata table, for instance.
    Returns the extent of the tiles in this data source.
    The bounds are in coordinate system of the projection of the data source.
    int
    Gets the current maximum overzoom level for this datasource.
    Over it the datasource will not be "drawn"
    int
    Returns the maximum zoom level supported by this data source.
    int
    Returns the maximum zoom level supported by this data source + getMaxOverzoomLevel if >= 0.
    Returns a copy of the data source meta data map.
    Returns a meta data element corresponding to the key.
    int
    Returns the minimum zoom level supported by this data source.
    Returns the projection of this tile source.
    boolean
     
    Loads the specified tile.
    Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.
    void
    notifyTilesChanged(boolean removeTiles)
    Notifies listeners that the tiles have changed.
    void
    setMaxOverzoomLevel(int overzoomLevel)
    Sets the maximum overzoom level for this datasource.
    If a tile for the given zoom level Z is not available, SDK will try to use tiles with zoom levels Z-1, ..., Z-MaxOverzoomLevel.
    The default is -1 (disabled).
    void
    Sets a new meta data map for the data source.
    void
    Adds a new key-value pair to the meta data map.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TileDataSource

      protected TileDataSource()
      Constructs an abstract TileDataSource object.
      Note: EPSG3857 projection is used. minZoom is defined to be 0, maxZoom is defined to be 24.
    • TileDataSource

      protected TileDataSource(int minZoom, int maxZoom)
      Constructs an abstract TileDataSource object.
      Note: EPSG3857 projection is used.
      Parameters:
      minZoom - The minimum zoom level supported by this data source.
      maxZoom - The maximum zoom level supported by this data source.
  • Method Details

    • getMinZoom

      public int getMinZoom()
      Returns the minimum zoom level supported by this data source.
      Returns:
      The minimum zoom level supported (inclusive).
    • getMaxZoom

      public int getMaxZoom()
      Returns the maximum zoom level supported by this data source.
      Returns:
      The maximum zoom level supported (exclusive).
    • getMaxZoomWithOverzoom

      public int getMaxZoomWithOverzoom()
      Returns the maximum zoom level supported by this data source + getMaxOverzoomLevel if >= 0.
      Returns:
      The maximum zoom level supported (exclusive).
    • setMaxOverzoomLevel

      public void setMaxOverzoomLevel(int overzoomLevel)
      Sets the maximum overzoom level for this datasource.
      If a tile for the given zoom level Z is not available, SDK will try to use tiles with zoom levels Z-1, ..., Z-MaxOverzoomLevel.
      The default is -1 (disabled).
      Parameters:
      overzoomLevel - The new maximum overzoom value.
    • getMaxOverzoomLevel

      public int getMaxOverzoomLevel()
      Gets the current maximum overzoom level for this datasource.
      Over it the datasource will not be "drawn"
      Returns:
      The current maximum overzoom level for this datasource.
    • isMaxOverzoomLevelSet

      public boolean isMaxOverzoomLevelSet()
    • getMetaData

      public StringVariantMap getMetaData()
      Returns a copy of the data source meta data map. The changes you make to this map are NOT reflected in the actual meta data of the source.
      The map is attached to every tile this source loads, and consumers read their settings
      from it - "dem_encoding" ("mapbox" or "terrarium") selects the elevation decoder, for instance.
      A wrapper source with no map of its own answers with its wrapped source's.
      Returns:
      A copy of the data source meta data map.
    • setMetaData

      public void setMetaData(StringVariantMap metaData)
      Sets a new meta data map for the data source. Old meta data values will be lost.
      Takes effect for tiles loaded after the call.
      Parameters:
      metaData - The new meta data map for this data source.
    • containsMetaDataKey

      public boolean containsMetaDataKey(String key)
      Returns true if the specified key exists in the data source meta data map, or in the
      container's own metadata.
      Parameters:
      key - The key to check.
      Returns:
      True if the meta data element exists.
    • getMetaDataElement

      public Variant getMetaDataElement(String key)
      Returns a meta data element corresponding to the key. Falls back to the container's own
      metadata (see getContainerMetaData) when the key was not set on the source itself.
      If no value is found null variant is returned.
      Parameters:
      key - The key to use.
      Returns:
      The value corresponding to the key, or an empty variant.
    • setMetaDataElement

      public void setMetaDataElement(String key, Variant element)
      Adds a new key-value pair to the meta data map. If the key already exists in the map,
      it's value will be replaced by the new value.
      Takes effect for tiles loaded after the call.
      Parameters:
      key - The new key.
      element - The new value.
    • getContainerMetaData

      public String getContainerMetaData(String key)
      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.
      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.
    • getDataExtent

      public MapBounds getDataExtent()
      Returns the extent of the tiles in this data source.
      The bounds are in coordinate system of the projection of the data source.
      Returns:
      The extent of the data source.
    • getProjection

      public Projection getProjection()
      Returns the projection of this tile source.
      Returns:
      The projection of this tile source.
    • loadTile

      public TileData loadTile(MapTile tile)
      Loads the specified tile.
      Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.
      Parameters:
      tile - The tile to load.
      Returns:
      The tile data. If the tile is not available, null may be returned.
    • notifyTilesChanged

      public void notifyTilesChanged(boolean removeTiles)
      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.
      Parameters:
      removeTiles - The remove tiles flag.
    • buildTagValues

      public StringMap buildTagValues(MapTile tile)
      Builds tag map from tile info.
      Parameters:
      tile - The tile for the tag map.
      Returns:
      The tag map that will be used for replacing tags in templates.