Skip to content

Commit 90faced

Browse files
authored
Merge pull request #1 from stacchain/nested-items
Add support for nested items
2 parents 9a75da2 + 310acbf commit 90faced

File tree

35 files changed

+756
-62
lines changed

35 files changed

+756
-62
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Fixed
1919

20+
## [v0.2.0] - 2024-11-16
21+
22+
### Added
23+
24+
- Enhanced collection processing to support nested subdirectories for items [#1](https://github.com/stacchain/stac-merkle-tree-cli/pull/1)
25+
- Test to ensure `merkle:root` values remain the same whether items are nested or not [#1](https://github.com/stacchain/stac-merkle-tree-cli/pull/1)
26+
2027
## [v0.1.1] - 2024-11-16
2128

2229
### Fixed

README.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,37 @@ pip install stac-merkle-tree-cli
6161

6262
## Directory Structure
6363

64-
Ensure your STAC catalog follows the directory structure below for optimal processing:
64+
Ensure your STAC catalog follows one of the directory structures below for optimal processing:
65+
66+
### Standard Flat Structure
67+
68+
In this structure, all items are at the same level as the `collection.json` file:
69+
70+
```bash
71+
collection/
72+
├── collection.json
73+
├── item1.json
74+
├── item2.json
75+
└── ...
76+
```
77+
78+
### Nested Structure
79+
80+
In this structure, items can be nested inside their own subdirectories within a collection:
81+
82+
```bash
83+
collection/
84+
├── collection.json
85+
├── item1/
86+
│ └── item1.json
87+
├── item2/
88+
│ └── item2.json
89+
└── ...
90+
```
91+
92+
### Catalog with Collections and Nested Items
93+
94+
A full STAC catalog with collections, where items can be either at the same level as the `collection.json` or nested within subdirectories:
6595

6696
```bash
6797
catalog/
@@ -70,13 +100,14 @@ catalog/
70100
│ ├── collection1/
71101
│ │ ├── collection.json
72102
│ │ ├── item1.json
73-
│ │ ├── item2.json
74-
│ │ └── ...
103+
│ │ ├── item2/
104+
│ │ └── item2.json
75105
│ ├── collection2/
76106
│ │ ├── collection.json
77-
│ │ ├── item1.json
78-
│ │ └── ...
79-
│ └── ...
107+
│ │ ├── item1/
108+
│ │ │ └── item1.json
109+
│ │ └── item2.json
110+
└── ...
80111
```
81112

82113
- **Catalog Level**:
@@ -86,7 +117,7 @@ catalog/
86117
- Each collection has its own directory inside `collections/`, named after the collection.
87118
- Inside each collection directory:
88119
- `collection.json`: Collection metadata.
89-
- `item.json`, `item2.json`, ...: Items belonging to the collection.
120+
- `item.json`, `item2.json`, ...: Items belonging to the collection, either at the same level or nested within subdirectories.
90121

91122
## Usage
92123

@@ -97,7 +128,7 @@ After installing the package, you can use the `stac-merkle-tree-cli` command to
97128
Navigate to the directory containing your catalog.json file and run the command as follows:
98129

99130
```bash
100-
stac-merkle-cli path/to/catalog.json
131+
stac-merkle-tree-cli path/to/catalog.json
101132
```
102133

103134
### Example
@@ -111,18 +142,19 @@ my_stac_catalog/
111142
│ ├── collection1/
112143
│ │ ├── collection.json
113144
│ │ ├── item1.json
114-
│ │ └── item2.json
145+
│ │ └── item2/
146+
│ │ └── item2.json
115147
│ └── collection2/
116148
│ ├── collection.json
117-
│ ├── item1.json
149+
│ ├── item1/
150+
│ │ └── item1.json
118151
│ └── item2.json
119-
120152
```
121153

122154
Run the tool:
123155

124156
```bash
125-
stac-merkle-tree-cli ./my_stac_catalog/catalog.json
157+
stac-merkle-tree-cli my_stac_catalog/catalog.json
126158
```
127159

128160
Expected Output:

example_catalog/catalog.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
"stac_extensions": [
5656
"https://stacchain.github.io/merkle-tree/v1.0.0/schema.json"
5757
],
58-
"merkle:object_hash": "b14fd102417c1d673f481bc053d19946aefdc27d84c584989b23c676c897bd5a",
59-
"merkle:root": "e3f79fe1a806f083fb6a3e5d7b052a0bed84f69c4b5c5969ddc4e39e0255f997",
58+
"merkle:object_hash": "4adf81a9aba90fe1f483ec3bbe7c628309e598239cee45d4aeafa1bc8c767ae6",
59+
"merkle:root": "6dcb155aa44f0384cf23af6843fb0505d752b11aaaa0778829889b9d598c176f",
6060
"merkle:hash_method": {
6161
"function": "sha256",
6262
"fields": [
6363
"*"
6464
],
6565
"ordering": "ascending",
66-
"description": "Computed by excluding Merkle fields and including merkle:object_hash values in ascending order to build the Merkle tree."
66+
"description": "Computed by including the merkle:root of collections and the catalogs own merkle:object_hash."
6767
}
6868
}

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101212T230244_20140325T230302_ADS_000000_1jTi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-12T23:02:44.000000Z",
4444
"end_datetime": "2014-03-25T23:03:02.000000Z",
4545
"start_datetime": "2010-12-12T23:02:44.000000Z",
46-
"merkle:object_hash": "ce9f56e695ab1751b8f0c8d9ef1f1ecedaf04574ec3077e70e7426ec9fc61ea4"
46+
"merkle:object_hash": "32c896520ed1fc38a93e59877cb6a88a5e795721eeae3bf6e7bd29206efb87af"
4747
},
4848
"bbox": [
4949
99,

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101212T230244_20140329T113710_ADS_000000_eAmG.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-12T23:02:44.000000Z",
4444
"end_datetime": "2014-03-29T11:37:10.000000Z",
4545
"start_datetime": "2010-12-12T23:02:44.000000Z",
46-
"merkle:object_hash": "ac66e07717b56e8421c8fec00b2b300afd49d30a8ec9c6d505df3b0568de9c77"
46+
"merkle:object_hash": "9c6b0b011ec783f4bcdec7c712c2443c3c6eca6d1a0d043842a7c8d587d767c4"
4747
},
4848
"bbox": [
4949
100,

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101215T103647_20130405T103047_ADS_000000_RHJx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-15T10:36:47.000000Z",
4444
"end_datetime": "2013-04-05T10:30:47.000000Z",
4545
"start_datetime": "2010-12-15T10:36:47.000000Z",
46-
"merkle:object_hash": "39969fd5f4a3a170ff39df8f2c13ebca66aab40890275a94ce798e281b85d54d"
46+
"merkle:object_hash": "762a6152760f8d4868e4036b2ad009a948485e2626c51c6db2a506fc2c7e491c"
4747
},
4848
"bbox": [
4949
98,

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101215T103647_20130405T103047_ADS_000000_oCX9.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-15T10:36:47.000000Z",
4444
"end_datetime": "2013-04-05T10:30:47.000000Z",
4545
"start_datetime": "2010-12-15T10:36:47.000000Z",
46-
"merkle:object_hash": "22a31ab988181f280a0bfc6872556ad1d670373bd997f711389d057e1b1f531a"
46+
"merkle:object_hash": "b56b4a839810159bfbcd77fe458bcf12173e796a6750b31399166c67cfd29c33"
4747
},
4848
"bbox": [
4949
100,

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101215T203649_20140913T090954_ADS_000000_4KBA.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-15T20:36:49.000000Z",
4444
"end_datetime": "2014-09-13T09:09:54.000000Z",
4545
"start_datetime": "2010-12-15T20:36:49.000000Z",
46-
"merkle:object_hash": "3c22648957e7c76f75a9fbfdf7c164e7d745d9e4ebe809db15d2474e01be4764"
46+
"merkle:object_hash": "df89c14ec6017be8ad68b8a51f1152671520a8959c65a7a377cfc2b789f30708"
4747
},
4848
"bbox": [
4949
135,

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101215T203649_20140913T090954_ADS_000000_Quqd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-15T20:36:49.000000Z",
4444
"end_datetime": "2014-09-13T09:09:54.000000Z",
4545
"start_datetime": "2010-12-15T20:36:49.000000Z",
46-
"merkle:object_hash": "6d16f23e2fe2849ce0316c012e9284b413f7c086a11d6de421c0582b397f513e"
46+
"merkle:object_hash": "7365039727dfa4456a355cd02585e713af706692716bf0b6050c1b8e82e1308f"
4747
},
4848
"bbox": [
4949
135,

example_catalog/collections/COP-DEM/DEM1_SAR_DGE_30_20101215T203914_20121226T204852_ADS_000000_Yjwo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"datetime": "2010-12-15T20:39:14.000000Z",
4444
"end_datetime": "2012-12-26T20:48:52.000000Z",
4545
"start_datetime": "2010-12-15T20:39:14.000000Z",
46-
"merkle:object_hash": "ed99b4348ede45959a9cf471490f0f2c6a106bb4337a46d07d4fc4b4988f099f"
46+
"merkle:object_hash": "b2bb980dc3b1d92106f009b6c732b7140533e622f3e06801dedd643eb9a8614c"
4747
},
4848
"bbox": [
4949
134,

0 commit comments

Comments
 (0)