Package org.geotools.mbtiles
Class MBTilesFile
Object
MBTilesFile
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataSourceconnection poolprotected booleanBoolean indicating if journal must be disabled or notprotected Filedatabase fileprotected static final LoggerLoggerprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final Stringstatic final Stringstatic final CoordinateReferenceSystemprotected final Stringprotected final Stringprotected final Stringprotected final Stringstatic 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 TypeMethodDescriptionvoidclose()Closes the mbtiles database connection.longclosestZoom(long zoomLevel) getFile()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.loadGrid(long zoomLevel, long column, long row) loadGrid(MBTilesGrid entry) loadMetaData(MBTilesMetadata metaData) protected StringloadMetaDataEntry(String name, Connection cx) loadTile(long zoomLevel, long column, long row) loadTile(MBTilesTile entry) longmaxColumn(long zoomLevel) longmaxRow(long zoomLevel) longmaxZoom()longminColumn(long zoomLevel) longminRow(long zoomLevel) longminZoom()intintnumberOfTiles(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 tiletiles()tiles(long zoomLevel) tiles(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 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:
closein interfaceAutoCloseable
-
getFile
The underlying database file.Note: this value may be
nulldepending 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
-