Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 3ab8d3f

Browse files
authored
Merge pull request #53 from unity-sds/stac_collection
added collection info to stac items
2 parents cd3fcdf + 8289272 commit 3ab8d3f

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
--------
99

10-
## UNRELEASED
1110

11+
12+
## [0.2.0] - 2023-08-10
1213
### Added
14+
* Added parsing of collection in stac items
1315
### Fixed
1416
* fixed release workflow to test against `unity-sds-client` not `unity_py`
1517
### Changed

tests/test_files/SNDR.SS1330.CHIRP.20160829T2317.m06.g233.L1_AQ.std.v02_48.G.200425130422.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"type": "Feature",
33
"stac_version": "1.0.0",
4+
"collection": "collection_test",
45
"id": "SNDR.SS1330.CHIRP.20160829T2317.m06.g233.L1_AQ.std.v02_48.G.200425130422",
56
"properties": {
67
"datetime": "2016-08-29T23:17:00Z",

tests/test_unity_stac.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def test_read_stac():
2323
datasets = collection.datasets
2424
assert len(datasets) == 2
2525

26+
# Added 8/10/23 to check the STAC collection information
27+
assert datasets[1].collection_id == 'C2011289787-GES_DISC'
28+
2629
data_files = collection.data_locations()
2730
assert len(data_files) == 6
2831
data_files = collection.data_locations(["data","opendap"])
@@ -37,6 +40,8 @@ def test_read_stac():
3740
#Try a "classic" catalog + item files stac catalog
3841
collection = Collection.from_stac("tests/test_files/catalog_01.json")
3942
datasets = collection.datasets
43+
# Added 8/10/23 to check the STAC collection information
44+
assert datasets[0].collection_id == 'collection_test'
4045
assert len(datasets) == 1
4146
data_files = collection.data_locations()
4247
assert len(data_files) == 2
@@ -102,6 +107,8 @@ def test_unity_to_stac():
102107
prop_count = 0
103108

104109
for d in collection._datasets:
110+
# Added 8/10/23 to check the STAC collection information
111+
assert d.collection_id == 'SNDR13CHRP1AQCal_rebin'
105112
for df in d.datafiles:
106113
assert application_output_directory in df.location
107114
assert os.path.isabs(df.location) == True

unity_sds_client/resources/collection.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def to_stac(collection, data_dir):
8888
id=dataset.id,
8989
geometry=dataset.geometry,
9090
bbox=dataset.bbox,
91+
collection=dataset.collection_id,
9192
datetime = date_parser.parse(dataset.data_begin_time),
9293
properties={
9394
"datetime": dataset.data_begin_time,
@@ -163,7 +164,17 @@ def from_stac(stac_file):
163164
collection = Collection(id)
164165
# Catch file not found... ?
165166
for item in items:
166-
ds = Dataset(item.id, item.properties.get("collection"), item.properties.get("start_datetime",None), item.properties.get("end_datetime", None), item.properties.get("created", None))
167+
# if the id of the catalog and the id of the collection items are not the same,
168+
# then use the one that is a part of the collection item definition
169+
# Added 8/10/23
170+
ds = Dataset(item.id, id, item.properties.get("start_datetime", None),
171+
item.properties.get("end_datetime", None), item.properties.get("created", None))
172+
if item.collection_id is not None and item.collection_id != id:
173+
print ("if2")
174+
ds = Dataset(item.id, item.collection_id, item.properties.get("start_datetime", None),
175+
item.properties.get("end_datetime", None), item.properties.get("created", None))
176+
177+
167178
ds.bbox = item.bbox
168179
ds.geometry = item.geometry
169180

0 commit comments

Comments
 (0)