Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rearranged create_stac.py to support TDE-1298 #1183

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions scripts/stac/imagery/create_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def create_item(
if not gdalinfo_result:
gdalinfo_result = gdal_info(asset_path)

geometry, bbox = get_extents(gdalinfo_result)

if derived_from is not None:
for derived in derived_from:
derived_item_content = read(derived)
Expand All @@ -130,7 +128,7 @@ def create_item(
)

item.update_datetime(start_datetime, end_datetime)
item.update_spatial(geometry, bbox)
item.update_spatial(*get_extents(gdalinfo_result))
item.add_collection(collection_id)

get_log().info("ImageryItem created", path=asset_path)
Expand All @@ -148,17 +146,8 @@ def create_base_item(asset_path: str, gdal_version: str) -> ImageryItem:
"""
id_ = get_file_name_from_path(asset_path)
file_content = fs.read(asset_path)
file_content_checksum = checksum.multihash_as_hex(file_content)
file_modified_datetime = format_rfc_3339_datetime_string(modified(asset_path))

stac_asset = STACAsset(
**{
"href": os.path.join(".", os.path.basename(asset_path)),
"file:checksum": checksum.multihash_as_hex(file_content),
"created": file_modified_datetime,
"updated": file_modified_datetime,
}
)

now_string = format_rfc_3339_datetime_string(utc_now())

if (topo_imagery_hash := os.environ.get("GIT_HASH")) is not None:
Expand All @@ -174,4 +163,13 @@ def create_base_item(asset_path: str, gdal_version: str) -> ImageryItem:
}
)

stac_asset = STACAsset(
**{
"href": os.path.join(".", os.path.basename(asset_path)),
"file:checksum": file_content_checksum,
"created": file_modified_datetime,
"updated": file_modified_datetime,
}
)

return ImageryItem(id_, now_string, stac_asset, stac_processing)
Loading