code: 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;
  	}
docs: Get the tile grid that includes the entire tile bounding box
  
  @param webMercatorBoundingBox
  web mercator bounding box
  @param zoom
  zoom level
  @return tile grid