Class TileData

java.lang.Object
com.massifmaps.datasources.components.TileData

public class TileData extends Object
A wrapper class for tile data.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a TileData object from a data blob.
    TileData(BinaryData pixels, int width, int height)
    Constructs a TileData object from RAW, already decoded pixels.

    For a source that produces pixels rather than a file - GDAL, a procedural tile, a
    decoder of a format the SDK does not know.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the specified key exists in the tile meta data map.
    boolean
    Checks if this object is equal to the specified object.
    Returns tile data as binary data.
    int
    The pixel height, or 0 when the data is an encoded file.
    long
    Returns the maximum age of the tile data, tile data will expire after that point.
    Returns a meta data element corresponding to the key.
    int
    The pixel width, or 0 when the data is an encoded file.
    int
    Returns the hash value of this object.
    boolean
    Returns true if the tile data source marked this as over zoom.
    boolean
    Returns true when getData() holds raw RGBA8 pixels rather than an encoded file.
    A consumer that turns tiles into bitmaps has to check this before decoding.
    boolean
    Returns true if the tile should be replaced with parent tile.
    void
    setIsOverZoom(boolean flag)
    Set the parent overzoom flag.
    void
    setMaxAge(long maxAge)
    Sets the maximum age of tile data, tile data will expire after that point.
    void
    Adds a new key-value pair to the meta data map, copying it first - the map is shared with
    every other tile of the same source.
    void
    setReplaceWithParent(boolean flag)
    Set the parent replacement flag.

    Methods inherited from class java.lang.Object

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

    • TileData

      public TileData(BinaryData data)
      Constructs a TileData object from a data blob.
      Parameters:
      data - The source tile data.
    • TileData

      public TileData(BinaryData pixels, int width, int height)
      Constructs a TileData object from RAW, already decoded pixels.

      For a source that produces pixels rather than a file - GDAL, a procedural tile, a
      decoder of a format the SDK does not know. The alternative is to encode a PNG the SDK
      then immediately decodes again, which is two codecs and three copies per tile.

      The layout is RGBA8, premultiplied, tightly packed: exactly width * height * 4 bytes,
      no row padding. One format on purpose - a second one would put a switch in every
      consumer for a case none of them has.

      Raster tiles only, and NOT persistently cached: the bytes carry no format, so a cache
      that stored them would read them back as a compressed file. See
      PersistentCacheTileDataSource::store.

      Parameters:
      pixels - width * height * 4 bytes of premultiplied RGBA.
      width - The tile width in pixels.
      height - The tile height in pixels.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getMaxAge

      public long getMaxAge()
      Returns the maximum age of the tile data, tile data will expire after that point.
      Returns:
      Tile data maximum age in milliseconds, or -1 if the data does not expire.
    • setMaxAge

      public void setMaxAge(long maxAge)
      Sets the maximum age of tile data, tile data will expire after that point.
      Parameters:
      maxAge - Tile data maximum age in milliseconds, or -1 if the data does not expire.
    • isReplaceWithParent

      public boolean isReplaceWithParent()
      Returns true if the tile should be replaced with parent tile.
      Returns:
      True if the tile should be replaced with parent. False otherwise.
    • setReplaceWithParent

      public void setReplaceWithParent(boolean flag)
      Set the parent replacement flag.
      Parameters:
      flag - True when the tile should be replaced with the parent, false otherwise.
    • isOverZoom

      public boolean isOverZoom()
      Returns true if the tile data source marked this as over zoom.
      Returns:
      True if the tile should not be drawn. False otherwise.
    • setIsOverZoom

      public void setIsOverZoom(boolean flag)
      Set the parent overzoom flag.
    • getData

      public BinaryData getData()
      Returns tile data as binary data.
      Returns:
      Tile data as binary data.
    • isRawPixels

      public boolean isRawPixels()
      Returns true when getData() holds raw RGBA8 pixels rather than an encoded file.
      A consumer that turns tiles into bitmaps has to check this before decoding.
      Returns:
      True if the data is raw pixels.
    • getWidth

      public int getWidth()
      The pixel width, or 0 when the data is an encoded file.
      Returns:
      The width in pixels.
    • getHeight

      public int getHeight()
      The pixel height, or 0 when the data is an encoded file.
      Returns:
      The height in pixels.
    • containsMetaDataKey

      public boolean containsMetaDataKey(String key)
      Returns true if the specified key exists in the tile meta data map.
      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. 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, copying it first - the map is shared with
      every other tile of the same source.
      Parameters:
      key - The new key.
      element - The new value.