def overview(input_mosaic, cogeo_profile, prefix, threads, overview_level, creation_options): """Create COG overviews for a mosaic.""" mosaic_def = get_mosaic_content(input_mosaic) output_profile = cog_profiles.get(cogeo_profile) output_profile.update(dict(BIGTIFF=os.environ.get("BIGTIFF", "IF_SAFER"))) if creation_options: output_profile.update(creation_options) config = dict( GDAL_NUM_THREADS="ALL_CPU", GDAL_TIFF_INTERNAL_MASK=os.environ.get("GDAL_TIFF_INTERNAL_MASK", True), GDAL_TIFF_OVR_BLOCKSIZE="128", ) if not prefix: prefix = os.path.basename(input_mosaic).split(".")[0] create_low_level_cogs( mosaic_def, output_profile, prefix, max_overview_level=overview_level, config=config, threads=threads, )
def _get_asset_example(mosaic_def: Dict) -> str: t = list(mosaic_def["tiles"].keys())[0] asset = mosaic_def["tiles"][t][0] if os.path.splitext(asset)[1] in [".json", ".gz"]: mosaic_def = get_mosaic_content(asset) return _get_asset_example(mosaic_def) return asset
def test_get_mosaic_S3ContentGz(requests, s3get): """Download Gzip mosaic file from S3.""" with open(mosaic_gz, "rb") as f: s3get.return_value = f.read() mosaic = utils.get_mosaic_content("s3://mybucket/mymosaic.json.gz") assert mosaic == mosaic_content requests.get.assert_not_called() s3get.assert_called_once()
def test_get_mosaic_HttpContentGz(requests, s3get): """Download Gzip mosaic file from http.""" with open(mosaic_gz, "rb") as f: requests.get.return_value = MockResponse(f.read()) mosaic = utils.get_mosaic_content("https://mymosaic.json.gz") assert mosaic == mosaic_content s3get.assert_not_called() requests.get.assert_called_once()
def update(input_files, input_mosaic, output, min_tile_cover, threads): """Update mosaic definition file.""" input_files = input_files.read().splitlines() mosaic_def = get_mosaic_content(input_mosaic) mosaic_spec = update_mosaic(input_files, mosaic_def, minimum_tile_cover=min_tile_cover, max_threads=threads) if output: with open(output, mode="w") as f: f.write(json.dumps(mosaic_spec)) else: click.echo(json.dumps(mosaic_spec))
def test_get_mosaic_ContentGz(requests, s3get): """Download Gzip mosaic.""" mosaic = utils.get_mosaic_content(mosaic_gz) assert mosaic == mosaic_content requests.get.assert_not_called() s3get.assert_not_called()
def test_get_mosaic_Content(requests, s3get): """Download mosaic file.""" mosaic = utils.get_mosaic_content(mosaic_json) assert mosaic == mosaic_content requests.get.assert_not_called() s3get.assert_not_called()