getTile method

List<int>? getTile(
  1. int tx,
  2. int tyOsm,
  3. int zoom
)

** Get a Tile's image bytes from the database.

@param tx the x tile index. @param tyOsm the y tile index, the osm way. @param zoom the zoom level. @return the tile image bytes. @throws Exception

Implementation

// * Add a list of tiles in batch mode.
// *
// * @param tilesList the list of tiles.
// * @throws Exception
// */
//public synchronized void addTilesInBatch( List<Tile> tilesList ) throws Exception {
//database.execOnConnection(connection -> {
//boolean autoCommit = connection.getAutoCommit();
//connection.setAutoCommit(false);
//try (IHMPreparedStatement pstmt = connection.prepareStatement(insertTileSql);) {
//for( Tile tile : tilesList ) {
//pstmt.setInt(1, tile.z);
//pstmt.setInt(2, tile.x);
//pstmt.setInt(3, tile.y);
//pstmt.setBytes(4, tile.imageBytes);
//pstmt.addBatch();
//}
//pstmt.executeBatch();
//return "";
//} finally {
//connection.setAutoCommit(autoCommit);
//}
//});
//}
//

/// Get a Tile's image bytes from the database.
///
/// @param tx the x tile index.
/// @param tyOsm the y tile index, the osm way.
/// @param zoom the zoom level.
/// @return the tile image bytes.
/// @throws Exception
List<int>? getTile(int tx, int tyOsm, int zoom) {
  int ty = tyOsm;
  if (tileRowType == "tms") {
    var tmsTileXY = osmTile2TmsTile(tx, tyOsm, zoom);
    ty = tmsTileXY[1];
  }

  var result = database.select(SELECTQUERY, [zoom, tx, ty]);
  if (result.length == 1) {
    return result.first.get(COL_TILES_TILE_DATA);
  }
  return null;
}