@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdMBTilesModelDecoder extends Object implements ILcdModelDecoder
File | Required | Entry point | Description |
---|---|---|---|
*.mbtiles | X | X | The database file |
This model decoder supports MBTiles files with image tiles (tile data formats jpg
or png
).
Files with vector tiles or grid tiles are not supported.
ILcdDataSourceModelDescriptor
.
ILcdEarthModelDescriptor
interface.ALcdImage
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.TLcdLockUtil.readLock(Object)
when accessing elements in the model.TLcdLockUtil.writeLock(Object)
when changing elements in the model.Decoding MBTiles data and visualizing it on a Lightspeed map:
//First create the model
ILcdModelDecoder decoder =
new TLcdCompositeModelDecoder(TLcdServiceLoader.getInstance(ILcdModelDecoder.class));
ILcdModel model = decoder.decode(sourceName);
//Create a layer for the model with default styling
ILspLayer layer = TLspRasterLayerBuilder.newBuilder()
.model(model)
.build();
//Add the layer to the Lightspeed view (an ILspView)
view.addLayer(layer);
Decoding MBTiles data and visualizing it on a GXY map:
//First create the model
ILcdModelDecoder decoder =
new TLcdCompositeModelDecoder(TLcdServiceLoader.getInstance(ILcdModelDecoder.class));
ILcdModel model = decoder.decode(sourceName);
//Create a layer for the model with default styling
ILcdGXYLayer layer = TLcdGXYLayer.create(model);
//Wrap the layer with an async layer wrapper to ensure
//that the view remains responsive while data is being painted
layer = ILcdGXYAsynchronousLayerWrapper.create(layer);
//Add the async layer to the GXY view (an ILcdGXYView)
view.addGXYLayer(layer);
Modifier and Type | Field and Description |
---|---|
static String |
TYPE_NAME
A general and human-readable type name for the MBTiles data format
|
Constructor and Description |
---|
TLcdMBTilesModelDecoder()
Creates a new MBTiles model decoder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
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.
|
ILcdModel |
decode(String aSource)
Decodes the single dataset in an MBTiles file.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a model for the given data source.
|
List<TLcdMBTilesDataSource> |
discoverDataSources(String aPath)
Returns the single data source in the given MBTiles file.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata, decodeModelMetadata
public static final String TYPE_NAME
public TLcdMBTilesModelDecoder()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(ILcdDataSource aDataSource)
This model decoder handles TLcdMBTilesDataSource
data sources and TLcdDataSource
data sources.
The latter case delegates the source to the canDecodeSource(String)
method.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- the dataset to be decoded.true
if the data source is a TLcdMBTilesDataSource
or a TLcdDataSource
, false
otherwisedecodeSource(com.luciad.model.ILcdDataSource)
public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
The data source must be a TLcdMBTilesDataSource
, which represents one data set
in the MBTiles file.
decodeSource
in interface ILcdModelDecoder
aDataSource
- the dataset to be decoded.class javadoc
IOException
- if the dataset cannot be loaded.canDecodeSource(com.luciad.model.ILcdDataSource)
public boolean canDecodeSource(String aSource)
This model decoder handles only .mbtiles
files.
canDecodeSource
in interface ILcdModelDecoder
aSource
- the data source to be verified; typically a file name or a URL.true
if the source has .mbtiles
extension.decode(String)
public ILcdModel decode(String aSource) throws IOException
decode
in interface ILcdModelDecoder
aSource
- the MBTiles file to be decoded.IOException
- if the file cannot be loaded.canDecodeSource(String)
public List<TLcdMBTilesDataSource> discoverDataSources(String aPath) throws IOException
decodeSource(com.luciad.model.ILcdDataSource)
to create a model for an individual data source.discoverDataSources
in interface ILcdModelDecoder
aPath
- A path to the data source to be decoded; typically a file name or a URL.IOException
- if the file cannot be read