diff --git a/scripts/collection_from_items.py b/scripts/collection_from_items.py index 131700637..a695ca75d 100644 --- a/scripts/collection_from_items.py +++ b/scripts/collection_from_items.py @@ -37,13 +37,6 @@ def main() -> None: parser.add_argument( "--location", dest="location", help="Optional Location of dataset, e.g. Hutt City", type=str, required=False ) - parser.add_argument( - "--geographic-description", - dest="geographic_description", - help="Optional Location Name, e.g. South Island", - type=str, - required=False, - ) parser.add_argument( "--start-date", dest="start_date", @@ -110,10 +103,9 @@ def main() -> None: "start_datetime": arguments.start_date, "end_datetime": arguments.end_date, "lifecycle": arguments.lifecycle, - "location": arguments.location, + "geographic_description": arguments.location, "event_name": arguments.event, "historic_survey_number": arguments.historic_survey_number, - "geographic_description": arguments.geographic_description, } collection = ImageryCollection( diff --git a/scripts/stac/imagery/collection.py b/scripts/stac/imagery/collection.py index 993e5d166..0609cf226 100644 --- a/scripts/stac/imagery/collection.py +++ b/scripts/stac/imagery/collection.py @@ -209,17 +209,20 @@ def write_to(self, destination: str) -> None: def _title(self) -> str: """Generates the title for imagery and elevation datasets. Satellite Imagery / Urban Aerial Photos / Rural Aerial Photos: - [Location / Region if no Location specified] [GSD] [?Event Name] [Data Sub-Type] ([Year(s)]) [?- Preview] + [geographic_description / Region if no geographic_description specified] [GSD] [?Event Name] [Data Sub-Type] + ([Year(s)]) [?- Preview] DEM / DSM: - [Location / Region if no Location specified] [?- Event Name] LiDAR [GSD] [Data Sub-Type] ([Year(s)]) [?- Preview] + [geographic_description / Region if no geographic_description specified] [?- Event Name] LiDAR [GSD] + [Data Sub-Type] ([Year(s)]) [?- Preview] If Historic Survey Number: - [Location / Region if no Location specified] [GSD] [Survey Number] ([Year(s)]) [?- Preview] + [geographic_description / Region if no geographic_description specified] [GSD] [Survey Number] ([Year(s)]) + [?- Preview] Returns: Dataset Title """ # format optional metadata - location = self.metadata.get("location") + geographic_description = self.metadata.get("geographic_description") historic_survey_number = self.metadata.get("historic_survey_number") event = self.metadata.get("event_name") @@ -230,8 +233,8 @@ def _title(self) -> str: date = f"{self.metadata['start_datetime'].year}-{self.metadata['end_datetime'].year}" # determine dataset name - if location: - name = location + if geographic_description: + name = geographic_description else: name = HUMAN_READABLE_REGIONS[self.metadata["region"]] @@ -268,7 +271,8 @@ def _description(self) -> str: Urban Aerial Photos / Rural Aerial Photos: Orthophotography within the [Region] region captured in the [Year(s)] flying season. DEM / DSM: - [Digital Surface Model / Digital Elevation Model] within the [region] [?- location] region in [year(s)]. + [Digital Surface Model / Digital Elevation Model] within the [region] + [?- geographic_description] region in [year(s)]. Satellite Imagery: Satellite imagery within the [Region] region captured in [Year(s)]. Historical Imagery: @@ -278,7 +282,7 @@ def _description(self) -> str: Dataset Description """ # format optional metadata - location = self.metadata.get("location") + geographic_description = self.metadata.get("geographic_description") historic_survey_number = self.metadata.get("historic_survey_number") event = self.metadata.get("event_name") @@ -288,9 +292,9 @@ def _description(self) -> str: else: date = f"{self.metadata['start_datetime'].year}-{self.metadata['end_datetime'].year}" - # format location for metadata description - if location: - location = f"- {location}" + # format geographic_description for metadata description + if geographic_description: + geographic_description = f"- {geographic_description}" region = HUMAN_READABLE_REGIONS[self.metadata["region"]] @@ -301,9 +305,13 @@ def _description(self) -> str: elif self.metadata["category"] in [URBAN_AERIAL_PHOTOS, RURAL_AERIAL_PHOTOS]: desc = f"Orthophotography within the {region} region captured in the {date} flying season" elif self.metadata["category"] == DEM: - desc = " ".join(f"Digital Elevation Model within the {region} {location or ''} region in {date}".split()) + desc = " ".join( + f"Digital Elevation Model within the {region} {geographic_description or ''} region in {date}".split() + ) elif self.metadata["category"] == DSM: - desc = " ".join(f"Digital Surface Model within the {region} {location or ''} region in {date}".split()) + desc = " ".join( + f"Digital Surface Model within the {region} {geographic_description or ''} region in {date}".split() + ) else: raise SubtypeParameterError(self.metadata["category"]) diff --git a/scripts/stac/imagery/metadata_constants.py b/scripts/stac/imagery/metadata_constants.py index e89db8f08..2bdf5b386 100644 --- a/scripts/stac/imagery/metadata_constants.py +++ b/scripts/stac/imagery/metadata_constants.py @@ -10,10 +10,9 @@ class CollectionMetadata(TypedDict): end_date: Dataset capture end date lifecycle: Dataset status Optional: - location: Optional location of dataset, e.g. Hutt City + geographic_description: Optional geographic_description of dataset, e.g. Hutt City event: Optional details of capture event, e.g. Cyclone Gabrielle historic_survey_number: Optional historic imagery survey number, e.g. SNC88445 - geographic_description: Optional location name, e.g. South Island """ category: str @@ -22,10 +21,9 @@ class CollectionMetadata(TypedDict): start_datetime: datetime end_datetime: datetime lifecycle: str - location: Optional[str] + geographic_description: Optional[str] event_name: Optional[str] historic_survey_number: Optional[str] - geographic_description: Optional[str] class SubtypeParameterError(Exception): diff --git a/scripts/stac/tests/collection_test.py b/scripts/stac/tests/collection_test.py index 5702a5d98..5524d572e 100644 --- a/scripts/stac/tests/collection_test.py +++ b/scripts/stac/tests/collection_test.py @@ -23,24 +23,23 @@ def setup() -> Generator[CollectionMetadata, None, None]: "start_datetime": datetime(2022, 2, 2), "end_datetime": datetime(2022, 2, 2), "lifecycle": "completed", - "location": None, "event_name": "Forest assessment", "historic_survey_number": None, - "geographic_description": "North Island", + "geographic_description": "Auckland North", } yield metadata def test_title_description_id_created_on_init(metadata: CollectionMetadata) -> None: collection = ImageryCollection(metadata) - assert collection.stac["title"] == "Auckland 0.3m Forest assessment Urban Aerial Photos (2022)" + assert collection.stac["title"] == "Auckland North 0.3m Forest assessment Urban Aerial Photos (2022)" assert ( collection.stac["description"] == "Orthophotography within the Auckland region captured in the 2022 flying season, published as a record of the Forest assessment event." # pylint: disable=line-too-long ) assert collection.stac["id"] assert collection.stac["linz:region"] == "auckland" - assert collection.stac["linz:geographic_description"] == "North Island" + assert collection.stac["linz:geographic_description"] == "Auckland North" assert collection.stac["linz:event_name"] == "Forest assessment" assert collection.stac["linz:lifecycle"] == "completed" assert collection.stac["linz:geospatial_category"] == "urban-aerial-photos" @@ -184,4 +183,4 @@ def test_event_name_is_present(metadata: CollectionMetadata) -> None: def test_geographic_description_is_present(metadata: CollectionMetadata) -> None: collection = ImageryCollection(metadata) - assert "North Island" == collection.stac["linz:geographic_description"] + assert "Auckland North" == collection.stac["linz:geographic_description"] diff --git a/scripts/stac/tests/generate_description_test.py b/scripts/stac/tests/generate_description_test.py index 18cf393b8..74c26cb0b 100644 --- a/scripts/stac/tests/generate_description_test.py +++ b/scripts/stac/tests/generate_description_test.py @@ -16,10 +16,9 @@ def setup() -> Generator[Tuple[CollectionMetadata, CollectionMetadata], None, No "start_datetime": datetime(2023, 1, 1), "end_datetime": datetime(2023, 2, 2), "lifecycle": "completed", - "location": None, + "geographic_description": None, "event_name": None, "historic_survey_number": None, - "geographic_description": None, } metadata_hb: CollectionMetadata = { "category": "rural-aerial-photos", @@ -28,10 +27,9 @@ def setup() -> Generator[Tuple[CollectionMetadata, CollectionMetadata], None, No "start_datetime": datetime(2023, 1, 1), "end_datetime": datetime(2023, 2, 2), "lifecycle": "completed", - "location": None, + "geographic_description": None, "event_name": None, "historic_survey_number": None, - "geographic_description": None, } yield (metadata_auck, metadata_hb) @@ -51,10 +49,12 @@ def test_generate_description_elevation(metadata: Tuple[CollectionMetadata, Coll assert collection.stac["description"] == description -def test_generate_description_elevation_location_input(metadata: Tuple[CollectionMetadata, CollectionMetadata]) -> None: +def test_generate_description_elevation_geographic_description_input( + metadata: Tuple[CollectionMetadata, CollectionMetadata] +) -> None: metadata_auck, _ = metadata metadata_auck["category"] = "dem" - metadata_auck["location"] = "Central" + metadata_auck["geographic_description"] = "Central" collection = ImageryCollection(metadata_auck) description = "Digital Elevation Model within the Auckland - Central region in 2023." assert collection.stac["description"] == description diff --git a/scripts/stac/tests/generate_title_test.py b/scripts/stac/tests/generate_title_test.py index b3852541e..a299db007 100644 --- a/scripts/stac/tests/generate_title_test.py +++ b/scripts/stac/tests/generate_title_test.py @@ -16,7 +16,6 @@ def setup() -> Generator[Tuple[CollectionMetadata, CollectionMetadata], None, No "start_datetime": datetime(2023, 1, 1), "end_datetime": datetime(2023, 2, 2), "lifecycle": "completed", - "location": None, "event_name": None, "historic_survey_number": None, "geographic_description": None, @@ -28,7 +27,6 @@ def setup() -> Generator[Tuple[CollectionMetadata, CollectionMetadata], None, No "start_datetime": datetime(2023, 1, 1), "end_datetime": datetime(2023, 2, 2), "lifecycle": "completed", - "location": None, "event_name": None, "historic_survey_number": None, "geographic_description": None, @@ -84,9 +82,9 @@ def test_generate_title_long_date(metadata: Tuple[CollectionMetadata, Collection assert collection.stac["title"] == title -def test_generate_title_location(metadata: Tuple[CollectionMetadata, CollectionMetadata]) -> None: +def test_generate_title_geographic_description(metadata: Tuple[CollectionMetadata, CollectionMetadata]) -> None: metadata_auck, _ = metadata - metadata_auck["location"] = "Ponsonby" + metadata_auck["geographic_description"] = "Ponsonby" collection = ImageryCollection(metadata_auck) title = "Ponsonby 0.3m Rural Aerial Photos (2023)" assert collection.stac["title"] == title @@ -129,7 +127,7 @@ def test_generate_dsm_title_preview(metadata: Tuple[CollectionMetadata, Collecti def test_generate_imagery_title_empty_optional_str(metadata: Tuple[CollectionMetadata, CollectionMetadata]) -> None: metadata_auck, _ = metadata - metadata_auck["location"] = "" + metadata_auck["geographic_description"] = "" metadata_auck["event_name"] = "" collection = ImageryCollection(metadata_auck) title = "Auckland 0.3m Rural Aerial Photos (2023)" diff --git a/scripts/stac/tests/item_test.py b/scripts/stac/tests/item_test.py index a97f3f876..aae3ca7fd 100644 --- a/scripts/stac/tests/item_test.py +++ b/scripts/stac/tests/item_test.py @@ -44,7 +44,6 @@ def test_imagery_add_collection(mocker) -> None: # type: ignore "start_datetime": datetime(2022, 2, 2), "end_datetime": datetime(2022, 2, 2), "lifecycle": "completed", - "location": None, "event_name": None, "historic_survey_number": None, "geographic_description": None,