Skip to content

Commit

Permalink
fix: add draft lifecycle tag
Browse files Browse the repository at this point in the history
  • Loading branch information
MDavidson17 committed May 15, 2024
1 parent 2828f14 commit 8f73ecd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/stac/imagery/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,20 @@ def _title(self) -> str:
imagery_name = region
elevation_description = None

# determine if dataset is preview
# determine if the dataset title requires a lifecycle tag
if self.metadata.get("lifecycle") == "preview":
preview = "- Preview"
lifecycle_tag = "- Preview"
elif self.metadata.get("lifecycle") == "ongoing":
lifecycle_tag = "- Draft"
else:
preview = None
lifecycle_tag = None

if self.metadata["category"] == SCANNED_AERIAL_PHOTOS:
if not historic_survey_number:
raise MissingMetadataError("historic_survey_number")
return " ".join(
value
for value in [imagery_name, self.metadata["gsd"], historic_survey_number, f"({date})", preview or None]
for value in [imagery_name, self.metadata["gsd"], historic_survey_number, f"({date})", lifecycle_tag or None]
if value is not None
)

Expand All @@ -292,7 +294,7 @@ def _title(self) -> str:
self.metadata["gsd"],
DATA_CATEGORIES[self.metadata["category"]],
f"({date})",
preview or None,
lifecycle_tag or None,
]
if value is not None
)
Expand All @@ -306,7 +308,7 @@ def _title(self) -> str:
self.metadata["gsd"],
DATA_CATEGORIES[self.metadata["category"]],
f"({date})",
preview or None,
lifecycle_tag or None,
]
if value is not None
)
Expand Down
8 changes: 8 additions & 0 deletions scripts/stac/imagery/tests/generate_title_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def test_generate_dsm_title_preview(metadata: Tuple[CollectionMetadata, Collecti
assert collection.stac["title"] == title


def test_generate_imagery_title_draft(metadata: Tuple[CollectionMetadata, CollectionMetadata]) -> None:
_, metadata_hb = metadata
metadata_hb["lifecycle"] = "ongoing"
collection = ImageryCollection(metadata_hb)
title = "Hawke's Bay 0.3m Rural Aerial Photos (2023) - Draft"
assert collection.stac["title"] == title


def test_generate_imagery_title_empty_optional_str(metadata: Tuple[CollectionMetadata, CollectionMetadata]) -> None:
metadata_auck, _ = metadata
metadata_auck["geographic_description"] = ""
Expand Down

0 comments on commit 8f73ecd

Please sign in to comment.