Package com.luciad.format.mbtiles
Class TLcdMBTilesModelDecoder
java.lang.Object
com.luciad.format.mbtiles.TLcdMBTilesModelDecoder
- All Implemented Interfaces:
ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdMBTilesModelDecoder
extends Object
implements ILcdModelDecoder
A model decoder for MBTiles files and services with either image or vector data.
Input
- An instance of
TLcdMBTilesDataSource
. - A String referring to a TileJSON endpoint of an MBTiles service.
- A String referring to an *.mbtiles file.
Supported files and services
This model decoder supports MBTiles files and services with image tiles (tile data formats jpg
or
png
) and vector tiles. WebP image tiles are not supported, nor are files that
use an IETF media type to describe their content.
Supported transfer protocols
- All transfer protocols that are supported by java.io.File.
- http
- https
Model structure
- This model decoder creates a model per MBTiles file or service.
Model descriptor
-
All models returned by this model decoder have an
ILcdDataSourceModelDescriptor
containing aTLcdMBTilesDataSource
. ThegetDataType()
method of the data source allows you to distinguish between image and vector tiles.
Model reference
- All models returned by this model decoder have a Web Mercator reference, aligned with the MBTiles specification.
Model elements
Image tiles
The decoded model contains a single implementation ofALcdImage
and ILcdEarthTileSet
.
The tiling structure of this tile set has world bounds defined in Web Mercator and a tile size of 256 by 256 pixels.
Vector tiles
The decoded model contains a singleILcdBounded
object
which represents the root node of the tile pyramid. No other information can be retrieved
from this object: it is not possible to query the model for specific vector tile features
or to select features using the API.
Instead, the features contained in a tile are only accessible through the layer on
which they are visualized, either when they are passed to a
styler
or via ILcdSelection
when the user selects them
using the mouse. Features which are thus obtained will have the following properties:
- Each feature is represented by an
ILcdDataObject
. You can retrieve its data type to learn which data properties the feature has. - The data object additionally has a property which contains the feature's geometry. This
property is annotated with
TLcdHasGeometryAnnotation
. Hence, the geometry of a feature can be retrieved by passing the data object toALcdShape#fromDomainObject()
. - The geometry is always a
shape list
with one or more elements. The elements can be eitherpoints
,polylines
,polygons
orcomplex polygons
. Furthermore, within a given shape list, all shapes will be of the same type.
Thread safety
- The decoded models are thread-safe for read access if you take a
read lock
. - The contents of the models are not meant to be edited.
Supported versions
- MBTiles, compliant with version 1.1, 1.2 or 1.3.
- TileJSON, compliant with version 3.0.
Further reading
The tutorial Working with MBTiles data provides more information and code examples of how to use MBTiles image and vector data in your applications. SeeTLspMBTilesVectorLayerBuilder
for more details on how to visualize vector tiles in a Lightspeed view.- Since:
- 2023.1
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(ILcdDataSource aDataSource) Checks whether the given data source can be decoded with this model decoder.boolean
canDecodeSource
(String aSource) Checks whether the given source can be decoded with this model decoder.Decodes the single dataset in an MBTiles file.decodeSource
(ILcdDataSource aDataSource) Creates a model for the given data source.discoverDataSources
(String aPath) Returns the single data source in the given MBTiles file.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns theILcdInputStreamFactory
that is used for creating input streams.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets theILcdInputStreamFactory
to be used for creating input streams.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
decodeModelMetadata, decodeModelMetadata
-
Field Details
-
TYPE_NAME
A general and human-readable type name for the MBTiles data format- See Also:
-
-
Constructor Details
-
TLcdMBTilesModelDecoder
public TLcdMBTilesModelDecoder()Creates a new MBTiles model decoder.
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
canDecodeSource
Checks whether the given data source can be decoded with this model decoder.This model decoder handles
TLcdMBTilesDataSource
data sources andTLcdDataSource
data sources. The latter case delegates the source to thecanDecodeSource(String)
method.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- the dataset to be decoded.- Returns:
true
if the data source is aTLcdMBTilesDataSource
or aTLcdDataSource
,false
otherwise.- See Also:
-
decodeSource
Creates a model for the given data source.The data source must be a
TLcdMBTilesDataSource
, which represents one data set in the MBTiles file.- Specified by:
decodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- the dataset to be decoded.- Returns:
- A model with the structure described in the
class javadoc
. - Throws:
IOException
- if the dataset cannot be loaded.- See Also:
-
canDecodeSource
Checks whether the given source can be decoded with this model decoder.This model decoder handles only
.mbtiles
files.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSource
- the data source to be verified; typically a file name or a URL.- Returns:
true
if the source has.mbtiles
extension.- See Also:
-
decode
Decodes the single dataset in an MBTiles file.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSource
- the MBTiles file to be decoded.- Returns:
- A model representing the dataset in the MBTiles file.
- Throws:
IOException
- if the file cannot be loaded.- See Also:
-
discoverDataSources
Returns the single data source in the given MBTiles file. You can usedecodeSource(com.luciad.model.ILcdDataSource)
to create a model for an individual data source.- Specified by:
discoverDataSources
in interfaceILcdModelDecoder
- Parameters:
aPath
- A path to the data source to be decoded; typically a file name or a URL.- Returns:
- the single data source in the given MBTiles file.
- Throws:
IOException
- if the file cannot be read
-
getInputStreamFactory
Returns theILcdInputStreamFactory
that is used for creating input streams. It's only used when theTLcdMBTilesDataSource.getSourceType()
isTLcdMBTilesDataSource.SourceType.SERVICE
.- Returns:
- the
ILcdInputStreamFactory
that is used for creating input streams. - Since:
- 2024.0
-
setInputStreamFactory
Sets theILcdInputStreamFactory
to be used for creating input streams. It's only used when theTLcdMBTilesDataSource.getSourceType()
isTLcdMBTilesDataSource.SourceType.SERVICE
.- Parameters:
aInputStreamFactory
- the input stream factory to be used by this model decoder.- Since:
- 2024.0
-