class_docstr: A WMTS imagery retriever which can be added to a map.
  
  Uses tile caching for fast repeated map retrievals.
  
  Note
  ----
      Requires owslib and Pillow to work.
class_docstr_tok: ["A","WMTS","imagery","retriever","which","can","be","added","to","a","map",".","Uses","tile","caching","for","fast","repeated","map","retrievals",".","Note","--","--","Requires","owslib","and","Pillow","to","work","."]
code: def _select_tiles(
      self,
      tile_matrix,
      tile_matrix_limits,
      tile_span_x,
      tile_span_y,
      extent,
  ):
      # Convert the requested extent from CRS coordinates to tile
      # indices. See annex H of the WMTS v1.0.0 spec.
      # NB. The epsilons get rid of any tiles which only just
      # (i.e. one part in a million) intrude into the requested
      # extent. Since these wouldn't be visible anyway there's nothing
      # to be gained by spending the time downloading them.
      min_x, max_x, min_y, max_y = extent
      matrix_min_x, matrix_max_y = tile_matrix.topleftcorner
      epsilon = 1e-6
      min_col = int((min_x - matrix_min_x) / tile_span_x + epsilon)
      max_col = int((max_x - matrix_min_x) / tile_span_x - epsilon)
      min_row = int((matrix_max_y - max_y) / tile_span_y + epsilon)
      max_row = int((matrix_max_y - min_y) / tile_span_y - epsilon)
      # Clamp to the limits of the tile matrix.
      min_col = max(min_col, 0)
      max_col = min(max_col, tile_matrix.matrixwidth - 1)
      min_row = max(min_row, 0)
      max_row = min(max_row, tile_matrix.matrixheight - 1)
      # Clamp to any layer-specific limits on the tile matrix.
      if tile_matrix_limits:
          min_col = max(min_col, tile_matrix_limits.mintilecol)
          max_col = min(max_col, tile_matrix_limits.maxtilecol)
          min_row = max(min_row, tile_matrix_limits.mintilerow)
          max_row = min(max_row, tile_matrix_limits.maxtilerow)
      return min_col, max_col, min_row, max_row
  
imports: import collections
  import io
  import math
  from urllib.parse import urlparse
  import warnings
  import weakref
  from xml.etree import ElementTree
  import numpy
  from PIL import Image
  import shapely.geometry
  import cartopy.crs
  from cartopy.img_transform import warp_array
  from cartopy.io import LocatedImage, RasterSource
label_desc: Use image node_id 7 for calling the WMTSRasterSource obj's underlying member method code with example usage: obj._select_tiles(tile_matrix, tile_matrix_limits, tile_span_x, tile_span_y, extent) and returns: min_col,  max_col,  min_row,  max_row