Package org.geotools.mbtiles
Class MBTilesFile
Object
MBTilesFile
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataSource
connection poolprotected boolean
Boolean indicating if journal must be disabled or notprotected File
database fileprotected static final Logger
Loggerprotected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
protected final String
static final String
static final CoordinateReferenceSystem
protected final String
protected final String
protected final String
protected final String
static final ReferencedEnvelope
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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
(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.MBTilesFile
(DataSource dataSource) Create an MBTilesFile from an SQL DataSource connected to an MBTiles file. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the mbtiles database connection.long
closestZoom
(long zoomLevel) 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 distancevoid
init()
Initializes the mbtiles database.protected void
init
(Connection cx) Initializes a mbtiles connection.loadGrid
(long zoomLevel, long column, long row) loadGrid
(MBTilesGrid entry) loadMetaData
(MBTilesMetadata metaData) protected String
loadMetaDataEntry
(String name, Connection cx) loadTile
(long zoomLevel, long column, long row) loadTile
(MBTilesTile entry) long
maxColumn
(long zoomLevel) long
maxRow
(long zoomLevel) long
maxZoom()
long
minColumn
(long zoomLevel) long
minRow
(long zoomLevel) long
minZoom()
int
int
numberOfTiles
(long zoomLevel) protected void
runScript
(String filename, Connection cx) void
saveGrid
(MBTilesGrid entry) Store a gridvoid
saveMetaData
(MBTilesMetadata metaData) Store MetaData in fileprotected 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 tiletiles()
tiles
(long zoomLevel) 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 oneprotected RectangleLong
toTilesRectangle
(Envelope envelope, long zoomLevel) Converts the envelope into a tiles rectangle containing it, at the requested zoom level.
-
Field Details
-
PRAGMA_JOURNAL_MODE_OFF
- See Also:
-
TABLE_METADATA
- See Also:
-
TABLE_TILES
- See Also:
-
TABLE_GRIDS
- See Also:
-
TABLE_GRID_DATA
- See Also:
-
MD_NAME
- See Also:
-
MD_TYPE
- See Also:
-
MD_VERSION
- See Also:
-
MD_DESCRIPTION
- See Also:
-
MD_FORMAT
- See Also:
-
MD_BOUNDS
- See Also:
-
MD_CENTER
- See Also:
-
MD_ATTRIBUTION
- See Also:
-
MD_MINZOOM
- See Also:
-
MD_MAXZOOM
- See Also:
-
MD_JSON
- See Also:
-
LOGGER
Logger -
SPHERICAL_MERCATOR
-
WORLD_ENVELOPE
-
file
database file -
connPool
connection pool -
disableJournal
protected boolean disableJournalBoolean indicating if journal must be disabled or not
-
-
Constructor Details
-
MBTilesFile
Creates a new empty MbTilesFile, generating a new file.- Throws:
IOException
-
MBTilesFile
Creates a new empty MbTilesFile, generating a new file, also deciding if journal must be disabled or not.This constructor assumes no credentials are required to connect to the database.
- Throws:
IOException
-
MBTilesFile
Creates a MbTilesFile from an existing file.This constructor assumes no credentials are required to connect to the database.
- Throws:
IOException
-
MBTilesFile
Creates a MbTilesFile from an existing file, also deciding if journal must be disabled or not.This constructor assumes no credentials are required to connect to the database.
- Throws:
IOException
-
MBTilesFile
public MBTilesFile(File file, String user, String passwd, boolean disableJournal) throws IOException Creates a MbTilesFile from an existing file specifying database credentials.- Throws:
IOException
-
MBTilesFile
Create an MBTilesFile from an SQL DataSource connected to an MBTiles file. Behaviour is undefined if the DataSource is any other form of database.
-
-
Method Details
-
saveMetaData
Store MetaData in file- Throws:
IOException
-
saveMinMaxZoomMetadata
Save the minimum and maximum zoom level as metadata items. GDAL and QGIS expect these items.- Parameters:
min
- The minimum zoom levelmax
- The maximum zoom level- Throws:
IOException
-
saveTile
Store a tile- Throws:
IOException
-
saveGrid
Store a grid- Throws:
IOException
-
loadMetaData
- Throws:
IOException
-
loadMetaData
- Throws:
IOException
-
loadTile
- Throws:
IOException
-
loadTile
- Throws:
IOException
-
loadGrid
- Throws:
IOException
-
loadGrid
- Throws:
IOException
-
tiles
- Throws:
SQLException
-
tiles
- Throws:
SQLException
-
tiles
public MBTilesFile.TileIterator tiles(long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile) throws SQLException - Throws:
SQLException
-
numberOfTiles
- Throws:
SQLException
-
numberOfTiles
- Throws:
SQLException
-
closestZoom
- Throws:
SQLException
-
minZoom
- Throws:
SQLException
-
maxZoom
- Throws:
SQLException
-
minColumn
- Throws:
SQLException
-
maxColumn
- Throws:
SQLException
-
minRow
- Throws:
SQLException
-
maxRow
- Throws:
SQLException
-
close
public void close()Closes the mbtiles database connection.The application should always call this method when done with a mbtiles to prevent connection leakage.
- Specified by:
close
in interfaceAutoCloseable
-
getFile
The underlying database file.Note: this value may be
null
depending on how the geopackage was initialized. -
saveMetaDataEntry
- Throws:
SQLException
-
loadMetaDataEntry
- Throws:
SQLException
-
init
Initializes the mbtiles database.This method creates all the necessary tables.
- Throws:
IOException
-
init
Initializes a mbtiles connection.This method creates all the necessary tables.
- Throws:
SQLException
-
runScript
- Throws:
SQLException
-
toTilesRectangle
Converts the envelope into a tiles rectangle containing it, at the requested zoom level. X tiles start from west and increase towards east, Y tiles start from north and increase towards south- Throws:
SQLException
-
tilesForZoom
protected static long tilesForZoom(long zoomLevel) -
getTileBounds
Returns the actual tile bounds for the given zoom level,- Throws:
SQLException
-
getZoomLevel
Returns the zoom level for the given simplification distance- Throws:
SQLException
-
toEnvelope
Converts the tile locations into a real world one- Parameters:
rect
- The tile rectangle, in tile spacezoom
- The zoom level
-
toEnvelope
-