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 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_CENTER |
protected String |
MD_DESCRIPTION |
protected String |
MD_FORMAT |
protected String |
MD_JSON |
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 |
static CoordinateReferenceSystem |
SPHERICAL_MERCATOR |
protected String |
TABLE_GRID_DATA |
protected String |
TABLE_GRIDS |
protected String |
TABLE_METADATA |
protected String |
TABLE_TILES |
static ReferencedEnvelope |
WORLD_ENVELOPE |
| 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.
|
protected RectangleLong |
getTileBounds(long zoomLevel,
boolean exact)
Returns the actual tile bounds for the given zoom level,
|
protected long |
getZoomLevel(double distance)
Returns the zoom level for the given simplification distance
|
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) |
protected static long |
tilesForZoom(long zoomLevel) |
protected static ReferencedEnvelope |
toEnvelope(MBTilesTileLocation tile) |
protected ReferencedEnvelope |
toEnvelope(RectangleLong rect,
long zoom)
Converts the tile locations into a real world one
|
protected RectangleLong |
toTilesRectangle(Envelope envelope,
long zoomLevel)
Converts the envelope into a tiles rectangle containing it, at the requested zoom level.
|
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_CENTER
protected final String MD_ATTRIBUTION
protected final String MD_MINZOOM
protected final String MD_MAXZOOM
protected final String MD_JSON
protected static final Logger LOGGER
public static final CoordinateReferenceSystem SPHERICAL_MERCATOR
public static final ReferencedEnvelope WORLD_ENVELOPE
protected File file
protected final DataSource connPool
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)
public void saveMetaData(MBTilesMetadata metaData) throws IOException
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
SQLExceptionprotected RectangleLong toTilesRectangle(Envelope envelope,
long zoomLevel)
throws SQLException
SQLExceptionprotected static long tilesForZoom(long zoomLevel)
protected RectangleLong getTileBounds(long zoomLevel,
boolean exact)
throws SQLException
SQLExceptionprotected long getZoomLevel(double distance)
throws SQLException
SQLExceptionprotected ReferencedEnvelope toEnvelope(RectangleLong rect, long zoom)
rect - The tile rectangle, in tile spacezoom - The zoom levelprotected static ReferencedEnvelope toEnvelope(MBTilesTileLocation tile)
Copyright © 1996–2021 Geotools. All rights reserved.