Here you can find the source of getMBTileData(int column, int row, int zoomLevel, String jdbcConnectionString)
Parameter | Description |
---|---|
column | The column of the tile. |
row | The row of the tile. |
zoomLevel | The zoom level of the tile. |
protected static byte[] getMBTileData(int column, int row, int zoomLevel, String jdbcConnectionString) throws Exception
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; public class Main { public static final String SQLITE_JDBC_DRIVER = "org.sqlite.JDBC"; /**// w ww . j a va2s .co m * Loads the MBTile data from the database as blob, and returns it as byte array. * * @param column * The column of the tile. * @param row * The row of the tile. * @param zoomLevel * The zoom level of the tile. * @return The tile as byte array with image information, or an empty array if not found. */ protected static byte[] getMBTileData(int column, int row, int zoomLevel, String jdbcConnectionString) throws Exception { Class.forName(SQLITE_JDBC_DRIVER); Connection conn = DriverManager.getConnection(jdbcConnectionString); Statement stat = conn.createStatement(); PreparedStatement prep = conn .prepareStatement("SELECT * FROM tiles WHERE tile_column = ? AND tile_row = ? AND zoom_level = ?;"); prep.setInt(1, column); prep.setInt(2, row); prep.setInt(3, zoomLevel); ResultSet rs = prep.executeQuery(); byte[] tileData = new byte[0]; while (rs.next()) { tileData = rs.getBytes("tile_data"); } rs.close(); stat.close(); conn.close(); return tileData; } }