bdc_catalog.utils
- bdc_catalog.utils.check_sum(file_path: str | BytesIO, chunk_size=16384) bytes
Read a file and generate a checksum using sha256.
- Raises:
IOError when could not open given file. –
- Parameters:
file_path (str|BytesIo) – Path to the file
chunk_size (int) – Size in bytes to read per iteration. Default is 16384 (16KB).
- Returns:
The digest value in bytes.
- bdc_catalog.utils.multihash_checksum_sha256(file_path: str | BytesIO)
Generate the checksum multihash.
This method follows the spec multihash. We use sha256 as described in
check_sum. The multihash spec defines the code 0x12 for sha256 and must have 0x20 (32 chars) length.See more in https://github.com/multiformats/py-multihash/blob/master/multihash/constants.py#L4
- Parameters:
file_path (str|BytesIo) – Path to the file
- Returns:
A string-like hash in hex-decimal
- bdc_catalog.utils.create_collection(name: str, version: Any, bands: list, category: str = 'eo', **kwargs) Tuple[Collection, bool]
Register a collection into database.
Note
Used from
bdc_catalog.cli.load_data()
- bdc_catalog.utils.create_item(collection_id: int, name: str, bbox: Any, footprint: Any, srid: int, start_date: str | datetime, is_available: bool = True, **kwargs)
Command helper to register an item.
Note
This helper does not check if item exists. Make sure to insert unique values otherwise may raise database unique constraint errors.
Note
Used from
bdc_catalog.cli.load_data()- Parameters:
collection_id (int) – The collection identifier
name (str) – The item name. It usually well-known as
scene_id.bbox (Any) – The bbox shapely geometry. Make sure to pass EPSG:4326 geom.
footprint (Any) – The footprint shapely geometry. Make sure to pass EPSG:4326 geom.
srid (int) – Spatial reference system identifier. Make sure you have it in database.
start_date (str|datetime) – Item date.
is_available (bool) – Item availability. Defaults to
True.
- Keyword Arguments:
end_date (Optional[str, datetime]) – Item end date. Defaults to
start_date.cloud_cover (Optional[float]) – Item cloud cover factor.
provider_id (Optional[int]) – The data provider identifier.
tile_id (Optional[int]) – Grid tile identifier