Class MBTilesHelper
- java.lang.Object
-
- org.hortonmachine.gears.modules.r.tmsgenerator.MBTilesHelper
-
- All Implemented Interfaces:
AutoCloseable
public class MBTilesHelper extends Object implements AutoCloseable
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOL_METADATA_NAMEstatic StringCOL_METADATA_VALUEstatic StringCOL_TILES_TILE_COLUMNstatic StringCOL_TILES_TILE_DATAstatic StringCOL_TILES_TILE_ROWstatic StringCOL_TILES_ZOOM_LEVELstatic StringSELECTQUERYstatic StringTABLE_METADATAstatic StringTABLE_TILESstatic intTILESIZEWe have a fixed tile size.
-
Constructor Summary
Constructors Constructor Description MBTilesHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTile(int x, int y, int z, BufferedImage image, String format)voidaddTileBatch(int x, int y, int z, BufferedImage image, String format, boolean sendBatch)voidclose()voidcreateIndexes()voidcreateTables(boolean makeIndexes)voidfillMetadata(float n, float s, float w, float e, String name, String format, int minZoom, int maxZoom)double[]getBounds()Get the bounds as [w,s,e,n]StringgetImageFormat()BufferedImagegetTile(int x, int y, int z)Get a Tile image from the database.static int[]getTileXY(double lat, double lon, int zoom)voidopen(File dbFile)static BufferedImagereadGridcoverageImageForTile(org.geotools.coverage.grid.io.AbstractGridCoverage2DReader reader, int x, int y, int zoom, org.opengis.referencing.crs.CoordinateReferenceSystem resampleCrs)Read the image of a tile from a generic geotools coverage reader.static org.locationtech.jts.geom.Envelopetile2boundingBox(int x, int y, int zoom)static doubletile2lat(int y, int z)static doubletile2lon(int x, int z)voidtriggerLastBatch()
-
-
-
Field Detail
-
TILESIZE
public static final int TILESIZE
We have a fixed tile size.- See Also:
- Constant Field Values
-
TABLE_TILES
public static final String TABLE_TILES
- See Also:
- Constant Field Values
-
COL_TILES_ZOOM_LEVEL
public static final String COL_TILES_ZOOM_LEVEL
- See Also:
- Constant Field Values
-
COL_TILES_TILE_COLUMN
public static final String COL_TILES_TILE_COLUMN
- See Also:
- Constant Field Values
-
COL_TILES_TILE_ROW
public static final String COL_TILES_TILE_ROW
- See Also:
- Constant Field Values
-
COL_TILES_TILE_DATA
public static final String COL_TILES_TILE_DATA
- See Also:
- Constant Field Values
-
SELECTQUERY
public static final String SELECTQUERY
- See Also:
- Constant Field Values
-
TABLE_METADATA
public static final String TABLE_METADATA
- See Also:
- Constant Field Values
-
COL_METADATA_NAME
public static final String COL_METADATA_NAME
- See Also:
- Constant Field Values
-
COL_METADATA_VALUE
public static final String COL_METADATA_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
open
public void open(File dbFile) throws SQLException
- Throws:
SQLException
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
createTables
public void createTables(boolean makeIndexes) throws SQLException- Throws:
SQLException
-
createIndexes
public void createIndexes() throws SQLException- Throws:
SQLException
-
fillMetadata
public void fillMetadata(float n, float s, float w, float e, String name, String format, int minZoom, int maxZoom) throws SQLException- Throws:
SQLException
-
addTile
public void addTile(int x, int y, int z, BufferedImage image, String format) throws Exception- Throws:
Exception
-
addTileBatch
public void addTileBatch(int x, int y, int z, BufferedImage image, String format, boolean sendBatch) throws Exception- Throws:
Exception
-
triggerLastBatch
public void triggerLastBatch()
-
getTile
public BufferedImage getTile(int x, int y, int z) throws Exception
Get a Tile image from the database.- Parameters:
x-y-z-- Returns:
- Throws:
Exception
-
getBounds
public double[] getBounds() throws ExceptionGet the bounds as [w,s,e,n]- Returns:
- Throws:
Exception
-
getImageFormat
public String getImageFormat() throws Exception
- Returns:
- the image format (jpg, png).
- Throws:
Exception
-
readGridcoverageImageForTile
public static BufferedImage readGridcoverageImageForTile(org.geotools.coverage.grid.io.AbstractGridCoverage2DReader reader, int x, int y, int zoom, org.opengis.referencing.crs.CoordinateReferenceSystem resampleCrs) throws IOException
Read the image of a tile from a generic geotools coverage reader.- Parameters:
reader- the reader, expected to be in CRS 3857.x- the tile x.y- the tile y.zoom- the zoomlevel.- Returns:
- the image.
- Throws:
IOException
-
tile2lon
public static double tile2lon(int x, int z)
-
tile2lat
public static double tile2lat(int y, int z)
-
getTileXY
public static int[] getTileXY(double lat, double lon, int zoom)
-
tile2boundingBox
public static org.locationtech.jts.geom.Envelope tile2boundingBox(int x, int y, int zoom)
-
-