Package org.geotools.mbtiles
Class MBTilesFile
- Object
- 
- MBTilesFile
 
- 
- All Implemented Interfaces:
- AutoCloseable
 
 public class MBTilesFile extends Object implements AutoCloseable 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classMBTilesFile.TileIterator
 - 
Field SummaryFields Modifier and Type Field Description protected DataSourceconnPoolconnection poolprotected booleandisableJournalBoolean indicating if journal must be disabled or notprotected Filefiledatabase fileprotected static LoggerLOGGERLoggerprotected StringMD_ATTRIBUTIONprotected StringMD_BOUNDSprotected StringMD_CENTERprotected StringMD_DESCRIPTIONprotected StringMD_FORMATprotected StringMD_JSONprotected StringMD_MAXZOOMprotected StringMD_MINZOOMprotected StringMD_NAMEprotected StringMD_TYPEprotected StringMD_VERSIONstatic StringPRAGMA_JOURNAL_MODE_OFFstatic CoordinateReferenceSystemSPHERICAL_MERCATORprotected StringTABLE_GRID_DATAprotected StringTABLE_GRIDSprotected StringTABLE_METADATAprotected StringTABLE_TILESstatic ReferencedEnvelopeWORLD_ENVELOPE
 - 
Constructor SummaryConstructors Constructor 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(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 SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the mbtiles database connection.longclosestZoom(long zoomLevel)FilegetFile()The underlying database file.protected RectangleLonggetTileBounds(long zoomLevel, boolean exact)Returns the actual tile bounds for the given zoom level,protected longgetZoomLevel(double distance)Returns the zoom level for the given simplification distancevoidinit()Initializes the mbtiles database.protected voidinit(Connection cx)Initializes a mbtiles connection.MBTilesGridloadGrid(long zoomLevel, long column, long row)MBTilesGridloadGrid(MBTilesGrid entry)MBTilesMetadataloadMetaData()MBTilesMetadataloadMetaData(MBTilesMetadata metaData)protected StringloadMetaDataEntry(String name, Connection cx)MBTilesTileloadTile(long zoomLevel, long column, long row)MBTilesTileloadTile(MBTilesTile entry)longmaxColumn(long zoomLevel)longmaxRow(long zoomLevel)longmaxZoom()longminColumn(long zoomLevel)longminRow(long zoomLevel)longminZoom()intnumberOfTiles()intnumberOfTiles(long zoomLevel)protected voidrunScript(String filename, Connection cx)voidsaveGrid(MBTilesGrid entry)Store a gridvoidsaveMetaData(MBTilesMetadata metaData)Store MetaData in fileprotected voidsaveMetaDataEntry(String name, String value, Connection cx)voidsaveMinMaxZoomMetadata(int min, int max)Save the minimum and maximum zoom level as metadata items.voidsaveTile(MBTilesTile entry)Store a tileMBTilesFile.TileIteratortiles()MBTilesFile.TileIteratortiles(long zoomLevel)MBTilesFile.TileIteratortiles(long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile)protected static longtilesForZoom(long zoomLevel)protected static ReferencedEnvelopetoEnvelope(MBTilesTileLocation tile)protected ReferencedEnvelopetoEnvelope(RectangleLong rect, long zoom)Converts the tile locations into a real world oneprotected RectangleLongtoTilesRectangle(Envelope envelope, long zoomLevel)Converts the envelope into a tiles rectangle containing it, at the requested zoom level.
 
- 
- 
- 
Field Detail- 
PRAGMA_JOURNAL_MODE_OFFpublic static final String PRAGMA_JOURNAL_MODE_OFF - See Also:
- Constant Field Values
 
 - 
TABLE_METADATAprotected final String TABLE_METADATA - See Also:
- Constant Field Values
 
 - 
TABLE_TILESprotected final String TABLE_TILES - See Also:
- Constant Field Values
 
 - 
TABLE_GRIDSprotected final String TABLE_GRIDS - See Also:
- Constant Field Values
 
 - 
TABLE_GRID_DATAprotected final String TABLE_GRID_DATA - See Also:
- Constant Field Values
 
 - 
MD_NAMEprotected final String MD_NAME - See Also:
- Constant Field Values
 
 - 
MD_TYPEprotected final String MD_TYPE - See Also:
- Constant Field Values
 
 - 
MD_VERSIONprotected final String MD_VERSION - See Also:
- Constant Field Values
 
 - 
MD_DESCRIPTIONprotected final String MD_DESCRIPTION - See Also:
- Constant Field Values
 
 - 
MD_FORMATprotected final String MD_FORMAT - See Also:
- Constant Field Values
 
 - 
MD_BOUNDSprotected final String MD_BOUNDS - See Also:
- Constant Field Values
 
 - 
MD_CENTERprotected final String MD_CENTER - See Also:
- Constant Field Values
 
 - 
MD_ATTRIBUTIONprotected final String MD_ATTRIBUTION - See Also:
- Constant Field Values
 
 - 
MD_MINZOOMprotected final String MD_MINZOOM - See Also:
- Constant Field Values
 
 - 
MD_MAXZOOMprotected final String MD_MAXZOOM - See Also:
- Constant Field Values
 
 - 
MD_JSONprotected final String MD_JSON - See Also:
- Constant Field Values
 
 - 
LOGGERprotected static final Logger LOGGER Logger
 - 
SPHERICAL_MERCATORpublic static final CoordinateReferenceSystem SPHERICAL_MERCATOR 
 - 
WORLD_ENVELOPEpublic static final ReferencedEnvelope WORLD_ENVELOPE 
 - 
fileprotected File file database file
 - 
connPoolprotected final DataSource connPool connection pool
 - 
disableJournalprotected boolean disableJournal Boolean indicating if journal must be disabled or not
 
- 
 - 
Constructor Detail- 
MBTilesFilepublic MBTilesFile() throws IOExceptionCreates a new empty MbTilesFile, generating a new file.- Throws:
- IOException
 
 - 
MBTilesFilepublic MBTilesFile(boolean disableJournal) throws IOExceptionCreates 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
 
 - 
MBTilesFilepublic MBTilesFile(File file) throws IOException Creates a MbTilesFile from an existing file.This constructor assumes no credentials are required to connect to the database. - Throws:
- IOException
 
 - 
MBTilesFilepublic MBTilesFile(File file, boolean disableJournal) throws IOException 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
 
 - 
MBTilesFilepublic MBTilesFile(File file, String user, String passwd, boolean disableJournal) throws IOException Creates a MbTilesFile from an existing file specifying database credentials.- Throws:
- IOException
 
 - 
MBTilesFilepublic MBTilesFile(DataSource dataSource) 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 Detail- 
saveMetaDatapublic void saveMetaData(MBTilesMetadata metaData) throws IOException Store MetaData in file- Throws:
- IOException
 
 - 
saveMinMaxZoomMetadatapublic void saveMinMaxZoomMetadata(int min, int max) throws IOExceptionSave the minimum and maximum zoom level as metadata items. GDAL and QGIS expect these items.- Parameters:
- min- The minimum zoom level
- max- The maximum zoom level
- Throws:
- IOException
 
 - 
saveTilepublic void saveTile(MBTilesTile entry) throws IOException Store a tile- Throws:
- IOException
 
 - 
saveGridpublic void saveGrid(MBTilesGrid entry) throws IOException Store a grid- Throws:
- IOException
 
 - 
loadMetaDatapublic MBTilesMetadata loadMetaData() throws IOException - Throws:
- IOException
 
 - 
loadMetaDatapublic MBTilesMetadata loadMetaData(MBTilesMetadata metaData) throws IOException - Throws:
- IOException
 
 - 
loadTilepublic MBTilesTile loadTile(long zoomLevel, long column, long row) throws IOException - Throws:
- IOException
 
 - 
loadTilepublic MBTilesTile loadTile(MBTilesTile entry) throws IOException - Throws:
- IOException
 
 - 
loadGridpublic MBTilesGrid loadGrid(long zoomLevel, long column, long row) throws IOException - Throws:
- IOException
 
 - 
loadGridpublic MBTilesGrid loadGrid(MBTilesGrid entry) throws IOException - Throws:
- IOException
 
 - 
tilespublic MBTilesFile.TileIterator tiles() throws SQLException - Throws:
- SQLException
 
 - 
tilespublic MBTilesFile.TileIterator tiles(long zoomLevel) throws SQLException - Throws:
- SQLException
 
 - 
tilespublic MBTilesFile.TileIterator tiles(long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile) throws SQLException - Throws:
- SQLException
 
 - 
numberOfTilespublic int numberOfTiles() throws SQLException- Throws:
- SQLException
 
 - 
numberOfTilespublic int numberOfTiles(long zoomLevel) throws SQLException- Throws:
- SQLException
 
 - 
closestZoompublic long closestZoom(long zoomLevel) throws SQLException- Throws:
- SQLException
 
 - 
minZoompublic long minZoom() throws SQLException- Throws:
- SQLException
 
 - 
maxZoompublic long maxZoom() throws SQLException- Throws:
- SQLException
 
 - 
minColumnpublic long minColumn(long zoomLevel) throws SQLException- Throws:
- SQLException
 
 - 
maxColumnpublic long maxColumn(long zoomLevel) throws SQLException- Throws:
- SQLException
 
 - 
minRowpublic long minRow(long zoomLevel) throws SQLException- Throws:
- SQLException
 
 - 
maxRowpublic long maxRow(long zoomLevel) throws SQLException- Throws:
- SQLException
 
 - 
closepublic 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:
- closein interface- AutoCloseable
 
 - 
getFilepublic File getFile() The underlying database file.Note: this value may be nulldepending on how the geopackage was initialized.
 - 
saveMetaDataEntryprotected void saveMetaDataEntry(String name, String value, Connection cx) throws SQLException - Throws:
- SQLException
 
 - 
loadMetaDataEntryprotected String loadMetaDataEntry(String name, Connection cx) throws SQLException - Throws:
- SQLException
 
 - 
initpublic void init() throws IOExceptionInitializes the mbtiles database.This method creates all the necessary tables. - Throws:
- IOException
 
 - 
initprotected void init(Connection cx) throws SQLException Initializes a mbtiles connection.This method creates all the necessary tables. - Throws:
- SQLException
 
 - 
runScriptprotected void runScript(String filename, Connection cx) throws SQLException - Throws:
- SQLException
 
 - 
toTilesRectangleprotected RectangleLong toTilesRectangle(Envelope envelope, long zoomLevel) throws SQLException 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
 
 - 
tilesForZoomprotected static long tilesForZoom(long zoomLevel) 
 - 
getTileBoundsprotected RectangleLong getTileBounds(long zoomLevel, boolean exact) throws SQLExceptionReturns the actual tile bounds for the given zoom level,- Throws:
- SQLException
 
 - 
getZoomLevelprotected long getZoomLevel(double distance) throws SQLExceptionReturns the zoom level for the given simplification distance- Throws:
- SQLException
 
 - 
toEnvelopeprotected ReferencedEnvelope toEnvelope(RectangleLong rect, long zoom) Converts the tile locations into a real world one- Parameters:
- rect- The tile rectangle, in tile space
- zoom- The zoom level
 
 - 
toEnvelopeprotected static ReferencedEnvelope toEnvelope(MBTilesTileLocation tile) 
 
- 
 
-