getZForResolution(resolution, opt_direction) {
    const z = linearFindNearest(
      this.resolutions_,
      resolution,
      opt_direction || 0,
    );
    return clamp(z, this.minZoom, this.maxZoom);
  }
@param {number} resolution Resolution.
@param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
    If 0, the nearest resolution will be used.
    If 1, the nearest higher resolution (lower Z) will be used. If -1, the
    nearest lower resolution (higher Z) will be used. Default is 0.
    Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.

For example to change tile Z at the midpoint of zoom levels
```js
function(value, high, low) {
  return value - low * Math.sqrt(high / low);
}
```
@return {number} Z.
@api