code: def compute_zoom_level(bounds, domain, levels):
      """
      Computes a zoom level given a bounds polygon, a polygon of the
      overall domain and the number of zoom levels to divide the data
      into.
  
      Parameters
      ----------
      bounds: shapely.geometry.Polygon
          Polygon representing the area of the current viewport
      domain: shapely.geometry.Polygon
          Polygon representing the overall bounding region of the data
      levels: int
          Number of zoom levels to divide the domain into
  
      Returns
      -------
      zoom_level: int
          Integer zoom level
      """
      area_fraction = min(bounds.area / domain.area, 1)
      return int(min(round(np.log2(1 / area_fraction)), levels))
  
file_path: geoviews/geoviews/operation/resample.py
imports: import param
  import numpy
  from holoviews import Polygons, Path
  from holoviews.streams import RangeXY
  from holoviews import Operation
  from shapely.geometry import Polygon
  from shapely.strtree import STRtree
  from ..util import polygons_to_geom_dicts, path_to_geom_dicts, shapely_v2
label_desc: Use image node_id 2 for calling a global function with example usage: compute_zoom_level(bounds, domain, levels) and returns: int