public class MBTilesFile extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
class |
MBTilesFile.TileIterator |
Modifier and Type | Field and Description |
---|---|
protected DataSource |
connPool
connection pool
|
protected JDBCDataStore |
dataStore
datastore for vector access, lazily created
|
protected boolean |
disableJournal
Boolean indicating if journal must be disabled or not
|
protected File |
file
database file
|
protected static Logger |
LOGGER
Logger
|
protected String |
MD_ATTRIBUTION |
protected String |
MD_BOUNDS |
protected String |
MD_DESCRIPTION |
protected String |
MD_FORMAT |
protected String |
MD_MAXZOOM |
protected String |
MD_MINZOOM |
protected String |
MD_NAME |
protected String |
MD_TYPE |
protected String |
MD_VERSION |
static String |
PRAGMA_JOURNAL_MODE_OFF |
protected String |
TABLE_GRID_DATA |
protected String |
TABLE_GRIDS |
protected String |
TABLE_METADATA |
protected String |
TABLE_TILES |
Constructor and Description |
---|
MBTilesFile()
Creates a new empty MbTilesFile, generating a new file.
|
MBTilesFile(boolean disableJournal)
Creates a new empty MbTilesFile, generating a new file, also deciding if journal must be
disabled or not.
|
MBTilesFile(DataSource dataSource)
Create an MBTilesFile from an SQL DataSource connected to an MBTiles file.
|
MBTilesFile(File file)
Creates a MbTilesFile from an existing file.
|
MBTilesFile(File file,
boolean disableJournal)
Creates a MbTilesFile from an existing file, also deciding if journal must be disabled or
not.
|
MBTilesFile(File file,
String user,
String passwd,
boolean disableJournal)
Creates a MbTilesFile from an existing file specifying database credentials.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the mbtiles database connection.
|
long |
closestZoom(long zoomLevel) |
File |
getFile()
The underlying database file.
|
void |
init()
Initializes the mbtiles database.
|
protected void |
init(Connection cx)
Initializes a mbtiles connection.
|
MBTilesGrid |
loadGrid(long zoomLevel,
long column,
long row) |
MBTilesGrid |
loadGrid(MBTilesGrid entry) |
MBTilesMetadata |
loadMetaData() |
MBTilesMetadata |
loadMetaData(MBTilesMetadata metaData) |
protected String |
loadMetaDataEntry(String name,
Connection cx) |
MBTilesTile |
loadTile(long zoomLevel,
long column,
long row) |
MBTilesTile |
loadTile(MBTilesTile entry) |
long |
maxColumn(long zoomLevel) |
long |
maxRow(long zoomLevel) |
long |
maxZoom() |
long |
minColumn(long zoomLevel) |
long |
minRow(long zoomLevel) |
long |
minZoom() |
int |
numberOfTiles() |
int |
numberOfTiles(long zoomLevel) |
protected void |
runScript(String filename,
Connection cx) |
void |
saveGrid(MBTilesGrid entry)
Store a grid
|
void |
saveMetaData(MBTilesMetadata metaData)
Store MetaData in file
|
protected void |
saveMetaDataEntry(String name,
String value,
Connection cx) |
void |
saveMinMaxZoomMetadata(int min,
int max)
Save the minimum and maximum zoom level as metadata items.
|
void |
saveTile(MBTilesTile entry)
Store a tile
|
MBTilesFile.TileIterator |
tiles() |
MBTilesFile.TileIterator |
tiles(long zoomLevel) |
MBTilesFile.TileIterator |
tiles(long zoomLevel,
long leftTile,
long bottomTile,
long rightTile,
long topTile) |
public static final String PRAGMA_JOURNAL_MODE_OFF
protected final String TABLE_METADATA
protected final String TABLE_TILES
protected final String TABLE_GRIDS
protected final String TABLE_GRID_DATA
protected final String MD_NAME
protected final String MD_TYPE
protected final String MD_VERSION
protected final String MD_DESCRIPTION
protected final String MD_FORMAT
protected final String MD_BOUNDS
protected final String MD_ATTRIBUTION
protected final String MD_MINZOOM
protected final String MD_MAXZOOM
protected static final Logger LOGGER
protected File file
protected final DataSource connPool
protected volatile JDBCDataStore dataStore
protected boolean disableJournal
public MBTilesFile() throws IOException
IOException
public MBTilesFile(boolean disableJournal) throws IOException
This constructor assumes no credentials are required to connect to the database.
IOException
public MBTilesFile(File file) throws IOException
This constructor assumes no credentials are required to connect to the database.
IOException
public MBTilesFile(File file, boolean disableJournal) throws IOException
This constructor assumes no credentials are required to connect to the database.
IOException
public MBTilesFile(File file, String user, String passwd, boolean disableJournal) throws IOException
IOException
public MBTilesFile(DataSource dataSource)
dataSource
- public void saveMetaData(MBTilesMetadata metaData) throws IOException
metaData
- IOException
public void saveMinMaxZoomMetadata(int min, int max) throws IOException
min
- The minimum zoom levelmax
- The maximum zoom levelIOException
public void saveTile(MBTilesTile entry) throws IOException
IOException
public void saveGrid(MBTilesGrid entry) throws IOException
IOException
public MBTilesMetadata loadMetaData() throws IOException
IOException
public MBTilesMetadata loadMetaData(MBTilesMetadata metaData) throws IOException
IOException
public MBTilesTile loadTile(long zoomLevel, long column, long row) throws IOException
IOException
public MBTilesTile loadTile(MBTilesTile entry) throws IOException
IOException
public MBTilesGrid loadGrid(long zoomLevel, long column, long row) throws IOException
IOException
public MBTilesGrid loadGrid(MBTilesGrid entry) throws IOException
IOException
public MBTilesFile.TileIterator tiles() throws SQLException
SQLException
public MBTilesFile.TileIterator tiles(long zoomLevel) throws SQLException
SQLException
public MBTilesFile.TileIterator tiles(long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile) throws SQLException
SQLException
public int numberOfTiles() throws SQLException
SQLException
public int numberOfTiles(long zoomLevel) throws SQLException
SQLException
public long closestZoom(long zoomLevel) throws SQLException
SQLException
public long minZoom() throws SQLException
SQLException
public long maxZoom() throws SQLException
SQLException
public long minColumn(long zoomLevel) throws SQLException
SQLException
public long maxColumn(long zoomLevel) throws SQLException
SQLException
public long minRow(long zoomLevel) throws SQLException
SQLException
public long maxRow(long zoomLevel) throws SQLException
SQLException
public void close()
The application should always call this method when done with a mbtiles to prevent connection leakage.
close
in interface AutoCloseable
public File getFile()
Note: this value may be null
depending on how the geopackage was initialized.
protected void saveMetaDataEntry(String name, String value, Connection cx) throws SQLException
SQLException
protected String loadMetaDataEntry(String name, Connection cx) throws SQLException
SQLException
public void init() throws IOException
This method creates all the necessary tables.
IOException
protected void init(Connection cx) throws SQLException
This method creates all the necessary tables.
SQLException
protected void runScript(String filename, Connection cx) throws SQLException
SQLException
Copyright © 1996–2019 Geotools. All rights reserved.