Get the tile from the request bounding box in the request projection

@param requestBoundingBox
request bounding box in the request projection
@return image
163334
public GeoPackageTile getTile(BoundingBox requestBoundingBox) {

		GeoPackageTile tile = null;

		// Transform to the projection of the tiles
		ProjectionTransform transformRequestToTiles = requestProjection
				.getTransformation(tilesProjection);
		BoundingBox tilesBoundingBox = requestBoundingBox
				.transform(transformRequestToTiles);

		List<TileMatrix> tileMatrices = getTileMatrices(tilesBoundingBox);

		for (int i = 0; tile == null && i < tileMatrices.size(); i++) {

			TileMatrix tileMatrix = tileMatrices.get(i);

			TileResultSet tileResults = retrieveTileResults(tilesBoundingBox,
					tileMatrix);
			if (tileResults != null) {

				try {

					if (tileResults.getCount() > 0) {

						BoundingBox requestProjectedBoundingBox = requestBoundingBox
								.transform(transformRequestToTiles);

						// Determine the requested tile dimensions, or use the
						// dimensions of a single tile matrix tile
						int requestedTileWidth = width != null ? width
								: (int) tileMatrix.getTileWidth();
						int requestedTileHeight = height != null ? height
								: (int) tileMatrix.getTileHeight();

						// Determine the size of the tile to initially draw
						int tileWidth = requestedTileWidth;
						int tileHeight = requestedTileHeight;
						if (!sameProjection) {
							tileWidth = (int) Math
									.round((requestProjectedBoundingBox
											.getMaxLongitude() - requestProjectedBoundingBox
											.getMinLongitude())
											/ tileMatrix.getPixelXSize());
							tileHeight = (int) Math
									.round((requestProjectedBoundingBox
											.getMaxLatitude() - requestProjectedBoundingBox
											.getMinLatitude())
											/ tileMatrix.getPixelYSize());
						}

						// Draw the resulting bitmap with the matching tiles
						GeoPackageTile geoPackageTile = drawTile(tileMatrix,
								tileResults, requestProjectedBoundingBox,
								tileWidth, tileHeight);

						// Create the tile
						if (geoPackageTile != null) {

							// Project the tile if needed
							if (!sameProjection
									&& geoPackageTile.getImage() != null) {
								BufferedImage reprojectTile = reprojectTile(
										geoPackageTile.getImage(),
										requestedTileWidth,
										requestedTileHeight,
										requestBoundingBox,
										transformRequestToTiles,
										tilesBoundingBox);
								geoPackageTile = new GeoPackageTile(
										requestedTileWidth,
										requestedTileHeight, reprojectTile);
							}

							tile = geoPackageTile;
						}

					}
				} finally {
					tileResults.close();
				}
			}
		}

		return tile;
	}
1029620
public boolean forceLoadTile(final OnlineTileSourceBase tileSource, final long pMapTileIndex) {
        try {
            final Drawable drawable = mTileDownloader.downloadTile(pMapTileIndex, mTileWriter, tileSource);
            return drawable != null;
        } catch (CantContinueException e) {
            return false;
        }
    }
1369293
public static CompositeOverlay getCompositeOverlay(TileDao tileDao, BoundedOverlay overlay) {
        List<TileDao> tileDaos = new ArrayList<>();
        tileDaos.add(tileDao);
        return getCompositeOverlay(tileDaos, overlay);
    }
517532
public BufferedImage getTile( int x, int y, int z ) throws Exception {
        try (PreparedStatement statement = connection.prepareStatement(SELECTQUERY)) {
            statement.setInt(1, z);
            statement.setInt(2, x);
            statement.setInt(3, y);
            ResultSet resultSet = statement.executeQuery();
            if (resultSet.next()) {
                byte[] imageBytes = resultSet.getBytes(1);
                boolean orig = ImageIO.getUseCache();
                ImageIO.setUseCache(false);
                InputStream in = new ByteArrayInputStream(imageBytes);
                BufferedImage bufferedImage = ImageIO.read(in);
                ImageIO.setUseCache(orig);
                return bufferedImage;
            }
        }
        return null;
    }
1185758
public static Rectangle getTile (
        int width, int height, int tileWidth, int tileHeight, int tileIndex)
    {
        Rectangle bounds = new Rectangle();
        getTile(width, height, tileWidth, tileHeight, tileIndex, bounds);
        return bounds;
    }
1247469
public BufferedImage drawTileQueryIndex(int x, int y, int zoom) {

		// Get the web mercator bounding box
		BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils
				.getWebMercatorBoundingBox(x, y, zoom);

		BufferedImage image = null;

		// Query for the geometry count matching the bounds in the index
		long tileCount = queryIndexedFeaturesCount(webMercatorBoundingBox);

		// Draw if at least one geometry exists
		if (tileCount > 0) {

			// Query for geometries matching the bounds in the index
			CloseableIterator<GeometryIndex> results = queryIndexedFeatures(webMercatorBoundingBox);

			try {

				if (maxFeaturesPerTile == null
						|| tileCount <= maxFeaturesPerTile.longValue()) {

					// Draw the tile image
					image = drawTile(zoom, webMercatorBoundingBox, results);

				} else if (maxFeaturesTileDraw != null) {

					// Draw the max features tile
					image = maxFeaturesTileDraw.drawTile(tileWidth, tileHeight,
							tileCount, results);
				}
			} finally {
				try {
					results.close();
				} catch (IOException e) {
					LOGGER.log(Level.WARNING,
							"Failed to close result set for query on x: " + x
									+ ", y: " + y + ", zoom: " + zoom, e);
				}
			}
		}

		return image;
	}
1350202
public Tile tile (IRectangle region) {
    return tile(region.x(), region.y(), region.width(), region.height());
  }
494679
@Override
    public Tile getTile(int x, int y, int zoom)
    {
        return getTile(x, y, zoom, true);
    }
1041320
public BoundingBox boundingBox() {
        BoundingBox boundingBox = new BoundingBox(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
        expandBoundingBox(boundingBox);
        return boundingBox;
    }
848949
def get_tile(tile_number):
    
    tile_number = int(tile_number)
    max_tiles = app.max_tiles
    if tile_number > max_tiles * max_tiles:
        raise TileOutOfBoundsError('Requested an out of bounds tile')

    tile_size = Point(
        app.img.size[0] // max_tiles, app.img.size[1] // max_tiles)
    tile_coords = Point(
        tile_number % max_tiles, tile_number // max_tiles)
    crop_box = (
        tile_coords.x * tile_size.x,
        tile_coords.y * tile_size.y,
        tile_coords.x * tile_size.x + tile_size.x,
        tile_coords.y * tile_size.y + tile_size.y,
    )
    return app.img.crop(crop_box)
975061
public TileScaling get() {
		TileScaling tileScaling = null;
		if (has()) {
			try {
				tileScaling = tileScalingDao.queryForId(tableName);
			} catch (SQLException e) {
				throw new GeoPackageException(
						"Failed to query for tile scaling for GeoPackage: "
								+ geoPackage.getName() + ", Tile Table: "
								+ tableName, e);
			}
		}
		return tileScaling;
	}
1289527
public Tile getAboveLeft() {
        int y = tileY - 1;
        int x = tileX - 1;
        if (y < 0) {
            y = getMaxTileNumber(this.zoomLevel);
        }
        if (x < 0) {
            x = getMaxTileNumber(this.zoomLevel);
        }
        return new Tile(x, y, this.zoomLevel, this.tileSize);
    }
1001495
public BufferedImage drawTile(int x, int y, int zoom) {
		BufferedImage image;
		if (isIndexQuery()) {
			image = drawTileQueryIndex(x, y, zoom);
		} else {
			image = drawTileQueryAll(x, y, zoom);
		}
		return image;
	}
1067336
public static TileGrid getTileGrid(BoundingBox webMercatorBoundingBox,
			int zoom) {

		int tilesPerSide = tilesPerSide(zoom);
		double tileSize = tileSize(tilesPerSide);

		int minX = (int) ((webMercatorBoundingBox.getMinLongitude() + ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) / tileSize);
		double tempMaxX = (webMercatorBoundingBox.getMaxLongitude() + ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH)
				/ tileSize;
		int maxX = (int) (tempMaxX - ProjectionConstants.WEB_MERCATOR_PRECISION);
		maxX = Math.min(maxX, tilesPerSide - 1);

		int minY = (int) (((webMercatorBoundingBox.getMaxLatitude() - ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) * -1) / tileSize);
		double tempMaxY = ((webMercatorBoundingBox.getMinLatitude() - ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) * -1)
				/ tileSize;
		int maxY = (int) (tempMaxY - ProjectionConstants.WEB_MERCATOR_PRECISION);
		maxY = Math.min(maxY, tilesPerSide - 1);

		TileGrid grid = new TileGrid(minX, minY, maxX, maxY);

		return grid;
	}
1071148
public GetImageResponse getImage(GetImageRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getImageId(), "request imageId should not be empty.");
        InternalRequest internalRequest =
                this.createRequest(request, HttpMethodName.GET, IMAGE_PREFIX, request.getImageId());
        return invokeHttpClient(internalRequest, GetImageResponse.class);
    }
64676
public BoundingBox getBoundingBox() {
        if (this.boundingBox == null) {
            double minLatitude = Math.max(MercatorProjection.LATITUDE_MIN, MercatorProjection.tileYToLatitude(tileY + 1, zoomLevel));
            double minLongitude = Math.max(-180, MercatorProjection.tileXToLongitude(this.tileX, zoomLevel));
            double maxLatitude = Math.min(MercatorProjection.LATITUDE_MAX, MercatorProjection.tileYToLatitude(this.tileY, zoomLevel));
            double maxLongitude = Math.min(180, MercatorProjection.tileXToLongitude(tileX + 1, zoomLevel));
            if (maxLongitude == -180) {
                // fix for dateline crossing, where the right tile starts at -180 and causes an invalid bbox
                maxLongitude = 180;
            }
            this.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
        }
        return this.boundingBox;
    }
96080
public BoundingBox boundingBoxFromWebMercator(BoundingBox boundingBox) {
        if (projection == null) {
            throw new GeoPackageException("Shape Converter projection is null");
        }
        return boundingBox.transform(fromWebMercator);
    }