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
IOExceptionpublic MBTilesFile(boolean disableJournal)
throws IOException
This constructor assumes no credentials are required to connect to the database.
IOExceptionpublic MBTilesFile(File file) throws IOException
This constructor assumes no credentials are required to connect to the database.
IOExceptionpublic MBTilesFile(File file, boolean disableJournal) throws IOException
This constructor assumes no credentials are required to connect to the database.
IOExceptionpublic MBTilesFile(File file, String user, String passwd, boolean disableJournal) throws IOException
IOExceptionpublic MBTilesFile(DataSource dataSource)
dataSource - public void saveMetaData(MBTilesMetadata metaData) throws IOException
metaData - IOExceptionpublic void saveMinMaxZoomMetadata(int min,
int max)
throws IOException
min - The minimum zoom levelmax - The maximum zoom levelIOExceptionpublic void saveTile(MBTilesTile entry) throws IOException
IOExceptionpublic void saveGrid(MBTilesGrid entry) throws IOException
IOExceptionpublic MBTilesMetadata loadMetaData() throws IOException
IOExceptionpublic MBTilesMetadata loadMetaData(MBTilesMetadata metaData) throws IOException
IOExceptionpublic MBTilesTile loadTile(long zoomLevel, long column, long row) throws IOException
IOExceptionpublic MBTilesTile loadTile(MBTilesTile entry) throws IOException
IOExceptionpublic MBTilesGrid loadGrid(long zoomLevel, long column, long row) throws IOException
IOExceptionpublic MBTilesGrid loadGrid(MBTilesGrid entry) throws IOException
IOExceptionpublic MBTilesFile.TileIterator tiles() throws SQLException
SQLExceptionpublic MBTilesFile.TileIterator tiles(long zoomLevel) throws SQLException
SQLExceptionpublic MBTilesFile.TileIterator tiles(long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile) throws SQLException
SQLExceptionpublic int numberOfTiles()
throws SQLException
SQLExceptionpublic int numberOfTiles(long zoomLevel)
throws SQLException
SQLExceptionpublic long closestZoom(long zoomLevel)
throws SQLException
SQLExceptionpublic long minZoom()
throws SQLException
SQLExceptionpublic long maxZoom()
throws SQLException
SQLExceptionpublic long minColumn(long zoomLevel)
throws SQLException
SQLExceptionpublic long maxColumn(long zoomLevel)
throws SQLException
SQLExceptionpublic long minRow(long zoomLevel)
throws SQLException
SQLExceptionpublic long maxRow(long zoomLevel)
throws SQLException
SQLExceptionpublic void close()
The application should always call this method when done with a mbtiles to prevent connection leakage.
close in interface AutoCloseablepublic 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
SQLExceptionprotected String loadMetaDataEntry(String name, Connection cx) throws SQLException
SQLExceptionpublic void init()
throws IOException
This method creates all the necessary tables.
IOExceptionprotected void init(Connection cx) throws SQLException
This method creates all the necessary tables.
SQLExceptionprotected void runScript(String filename, Connection cx) throws SQLException
SQLExceptionCopyright © 1996–2019 Geotools. All rights reserved.