parameters: (src_path)
docstring: Guarantee that the .tif passed as an argument is a Cloud Optimized GeoTIFF (cogeo)
      If the path is not a cogeo, it is destructively converted into a cogeo.
      If the file cannot be converted, the function does not change the file
      :param src_path: path to GeoTIFF (cogeo or not)
      :return: None
docstring_summary: Guarantee that the .tif passed as an argument is a Cloud Optimized GeoTIFF (cogeo)
      If the path is not a cogeo, it is destructively converted into a cogeo.
      If the file cannot be converted, the function does not change the file
      :param src_path: path to GeoTIFF (cogeo or not)
      :return: None
docstring_tokens: Guarantee that the . tif passed as an argument is a Cloud Optimized GeoTIFF ( cogeo ) If the path is not a cogeo it is destructively converted into a cogeo . If the file cannot be converted the function does not change the file : param src_path : path to GeoTIFF ( cogeo or not ) : return : None
function: def assure_cogeo(src_path):
      """
      Guarantee that the .tif passed as an argument is a Cloud Optimized GeoTIFF (cogeo)
      If the path is not a cogeo, it is destructively converted into a cogeo.
      If the file cannot be converted, the function does not change the file
      :param src_path: path to GeoTIFF (cogeo or not)
      :return: None
      """
  
      if not os.path.isfile(src_path):
          logger.warning("Cannot validate cogeo: %s (file does not exist)" % src_path)
          return
  
      if valid_cogeo(src_path):
          return
  
      # Not a cogeo
      logger.info("Optimizing %s as Cloud Optimized GeoTIFF" % src_path)
  
      # Check if we have GDAL >= 3.1
      use_legacy = False
      gdal_version = get_gdal_version()
      if gdal_version:
          major, minor, build = gdal_version
          
          # GDAL 2 and lower
          if major <= 2:
              use_legacy = True
          
          # GDAL 3.0 and lower
          if major == 3 and minor < 1:
              use_legacy = True
      else:
          # This shouldn't happen
          use_legacy = True
          
      if use_legacy:
          logger.warning("Using legacy implementation (GDAL >= 3.1 not found)")
          return make_cogeo_legacy(src_path)
      else:
          return make_cogeo_gdal(src_path)
function_tokens: def assure_cogeo ( src_path ) : if not os . path . isfile ( src_path ) : logger . warning ( "Cannot validate cogeo: %s (file does not exist)" % src_path ) return if valid_cogeo ( src_path ) : return # Not a cogeo logger . info ( "Optimizing %s as Cloud Optimized GeoTIFF" % src_path ) # Check if we have GDAL >= 3.1 use_legacy = False gdal_version = get_gdal_version ( ) if gdal_version : major , minor , build = gdal_version # GDAL 2 and lower if major <= 2 : use_legacy = True # GDAL 3.0 and lower if major == 3 and minor < 1 : use_legacy = True else : # This shouldn't happen use_legacy = True if use_legacy : logger . warning ( "Using legacy implementation (GDAL >= 3.1 not found)" ) return make_cogeo_legacy ( src_path ) else : return make_cogeo_gdal ( src_path )