public class

MBTilesTileDataSource

extends TileDataSource
java.lang.Object
   ↳ com.carto.datasources.TileDataSource
     ↳ com.carto.datasources.MBTilesTileDataSource

Class Overview

A tile data source that loads tiles from a local Sqlite database.
The database must contain table "tiles" with the following fields:
"zoom_level" (tile zoom level), "tile_column" (tile x coordinate),
"tile_row" (tile y coordinate), "tile_data" (compressed tile image).

Summary

Public Constructors
MBTilesTileDataSource(String path)
Constructs a MBTilesTileDataSource object.
MBTilesTileDataSource(int minZoom, int maxZoom, String path)
Constructs a MBTilesTileDataSource object.
MBTilesTileDataSource(int minZoom, int maxZoom, String path, MBTilesScheme scheme)
Constructs a MBTilesTileDataSource object with specified tile scheme.
Public Methods
synchronized void delete()
MapBounds getDataExtent()
Returns the extent of the tiles in this data source.
StringMap getMetaData()
Get data source metadata information.
TileData loadTile(MapTile mapTile)
Loads the specified tile.
[Expand]
Inherited Methods
From class com.carto.datasources.TileDataSource
From class java.lang.Object

Public Constructors

public MBTilesTileDataSource (String path)

Constructs a MBTilesTileDataSource object. TMS tile scheme is used,
Min and max zoom levels are automatically detected.

Parameters
path The path to the local Sqlite database file.
Throws
Exception If the the file could not be opened.
IOException

public MBTilesTileDataSource (int minZoom, int maxZoom, String path)

Constructs a MBTilesTileDataSource object. TMS tile scheme is used.

Parameters
minZoom The minimum zoom level supported by this data source.
maxZoom The maximum zoom level supported by this data source.
path The path to the local Sqlite database file.
Throws
Exception If the the file could not be opened.
IOException

public MBTilesTileDataSource (int minZoom, int maxZoom, String path, MBTilesScheme scheme)

Constructs a MBTilesTileDataSource object with specified tile scheme.

Parameters
minZoom The minimum zoom level supported by this data source.
maxZoom The maximum zoom level supported by this data source.
path The path to the local Sqlite database file.
scheme Tile scheme to use.
Throws
Exception If the the file could not be opened.
IOException

Public Methods

public synchronized void delete ()

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.

public StringMap getMetaData ()

Get data source metadata information.
Possible parameters can be found in MBTiles specification.

Returns
  • Map containing meta data information (parameter names mapped to parameter values).

public TileData loadTile (MapTile mapTile)

Loads the specified tile.
Note: the tile coordinate system used here is vertically flipped relative to layer tile coordinate system.

Parameters
mapTile The tile to load.
Returns
  • The tile data. If the tile is not available, null may be returned.