Beispiel #1
0
def provision(
    bbox: BBOX,
    base_url: str,
    wms_properties: WmsProperties,
    wms_crs_code: str,
    layers: Tuple[str],
    styles: Tuple[str],
    scales: Tuple[int],
    image_format: str,
    cache_dir_name: str,
    run_id: str,
) -> Dict[int, List[str]]:
    cache_directory = get_cache_path((cache_dir_name,))
    run_directory = get_run_data_path(run_id, (cache_dir_name,))
    os.makedirs(run_directory)
    grid = _build_grid_for_bbox(bbox, wms_crs_code, scales, wms_properties)
    grid_for_retrieval = _update_grid_for_retrieval(
        base_url,
        grid,
        layers,
        styles,
        wms_crs_code,
        image_format,
        cache_directory,
        run_directory,
    )
    grid_for_missing = _filter_grid_for_missing(grid_for_retrieval)
    requests = _convert_grid_to_requests(grid_for_missing, image_format)
    retrieve(requests)
    if image_format != TARGET_FILE_FORMAT:
        _convert_to_tif(grid_for_missing, wms_crs_code)
    return _create_run_output(bbox, grid_for_retrieval, run_id)
def provision(
    bbox: BBOX,
    url_template: str,
    zoom_min: int,
    zoom_max: int,
    image_format: str,
    file_extension: str = None,
) -> ProvisionResult:
    tiles = _identify_tiles(bbox, zoom_min, zoom_max)
    retrieve(
        _build_retrieval_requests(tiles, url_template, image_format, file_extension,)
    )
    return ProvisionResult(
        tile_dir=get_output_dir(url_template),
        tile_paths=_build_tile_paths(tiles, url_template, image_format, file_extension),
    )
Beispiel #3
0
def provision(
    bbox: BBOX,
    url_template: str,
    zoom_min: int,
    zoom_max: int,
    image_formats: List[str],
    file_extension: str = None,
) -> ProvisionResult:
    tiles = _identify_tiles(bbox, zoom_min, zoom_max)
    retrieve(
        _build_retrieval_requests(tiles, url_template, image_formats, file_extension),
        HTTP_RETRIEVAL_CONCURRENCY,
    )
    return ProvisionResult(
        tile_dir=get_output_dir(url_template),
        tile_paths=_build_tile_paths(tiles, url_template, file_extension),
    )
                cell_name=cell_name,
                tif_name=f"{cell_name}.tif",
                tif_path=get_cache_path((CACHE_DIR_NAME, f"{cell_name}.tif")),
                prj_path=get_cache_path(
                    (CACHE_DIR_NAME, f"{cell_name}_prj.tif")),
                run_path=get_run_data_path(
                    run_id, (CACHE_DIR_NAME, f"{cell_name}.tif")),
            ))

    to_generate = list(
        filter(
            lambda generation_request: not skip_file_creation(
                generation_request.prj_path),
            bbox_cells,
        ))
    retrieve(to_generate, HTTP_RETRIEVAL_CONCURRENCY)

    for generation_request in to_generate:
        try:
            with zipfile.ZipFile(generation_request.path, "r") as zip_ref:
                zip_ref.extract(generation_request.tif_name,
                                get_cache_path((CACHE_DIR_NAME, )))
            Warp(
                generation_request.prj_path,
                generation_request.tif_path,
                cutlineDSName=get_data_path(("grids.gpkg", )),
                cutlineLayer="BC-20000",
                cutlineWhere=f"MAP_TILE = '{generation_request.cell_name}'",
                cropToCutline=False,
                cutlineBlend=1,
                dstNodata=-1,
Beispiel #5
0
                        (CACHE_DIR_NAME, f"{cell_part_name}.dem")),
                    prj_path=get_cache_path(
                        (CACHE_DIR_NAME, f"{cell_part_name}_prj.tif")),
                    hs_path=get_cache_path(
                        (CACHE_DIR_NAME, f"{cell_part_name}_hs.tif")),
                    run_path=get_run_data_path(
                        run_id, (CACHE_DIR_NAME, f"{cell_part_name}.tif")),
                ))

    to_generate = list(
        filter(
            lambda generation_request: not skip_file_creation(
                generation_request.hs_path),
            bbox_cells,
        ))
    retrieve(to_generate)

    for generation_request in to_generate:
        with zipfile.ZipFile(generation_request.path, "r") as zip_ref:
            zip_ref.extractall(get_cache_path((CACHE_DIR_NAME, )))
        Warp(
            generation_request.prj_path,
            generation_request.dem_path,
            srcSRS="EPSG:4269",
            dstSRS=OUTPUT_CRS_CODE,
            resampleAlg="cubic",
        )
        DEMProcessing(
            generation_request.hs_path,
            generation_request.prj_path,
            "hillshade",