Class TileData
java.lang.Object
com.massifmaps.datasources.components.TileData
A wrapper class for tile data.
-
Constructor Summary
ConstructorsConstructorDescriptionTileData(BinaryData data) 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 TypeMethodDescriptionbooleanReturns true if the specified key exists in the tile meta data map.booleanChecks if this object is equal to the specified object.getData()Returns tile data as binary data.intThe pixel height, or 0 when the data is an encoded file.longReturns the maximum age of the tile data, tile data will expire after that point.getMetaDataElement(String key) Returns a meta data element corresponding to the key.intgetWidth()The pixel width, or 0 when the data is an encoded file.inthashCode()Returns the hash value of this object.booleanReturns true if the tile data source marked this as over zoom.booleanReturns 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.booleanReturns true if the tile should be replaced with parent tile.voidsetIsOverZoom(boolean flag) Set the parent overzoom flag.voidsetMaxAge(long maxAge) Sets the maximum age of tile data, tile data will expire after that point.voidsetMetaDataElement(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.voidsetReplaceWithParent(boolean flag) Set the parent replacement flag.
-
Constructor Details
-
TileData
Constructs a TileData object from a data blob.- Parameters:
data- The source tile data.
-
TileData
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
Checks if this object is equal to the specified object. -
hashCode
public int hashCode()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
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
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
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
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.
-