Skip to content

Commit 06cf1f2

Browse files
committed
Merge branch 'issue699-stac11-band-support'
2 parents bdbc805 + 81d0d84 commit 06cf1f2

File tree

11 files changed

+3746
-140
lines changed

11 files changed

+3746
-140
lines changed

CHANGELOG.md

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

1010
### Added
1111

12+
- More extensive band detection for `load_stac` use cases, including the common `bands` metadata introduced with STAC 1.1 ([#699](https://github.com/Open-EO/openeo-python-client/issues/699), [#692](https://github.com/Open-EO/openeo-python-client/issues/692), [#586](https://github.com/Open-EO/openeo-python-client/issues/586)).
13+
1214
### Changed
1315

1416
- `openeo.UDF()`: automatically un-indent given UDF code ([#782](https://github.com/Open-EO/openeo-python-client/issues/782))

openeo/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.43.0a2"
1+
__version__ = "0.43.0a3"

openeo/metadata.py

Lines changed: 268 additions & 109 deletions
Large diffs are not rendered by default.

openeo/testing/stac.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def collection(
6565
extent: Optional[dict] = None,
6666
cube_dimensions: Optional[dict] = None,
6767
summaries: Optional[dict] = None,
68+
links: Optional[List[dict]] = None,
69+
**kwargs,
6870
) -> dict:
6971
"""Create a STAC Collection represented as dictionary."""
7072
if extent is None:
@@ -77,7 +79,8 @@ def collection(
7779
"description": description,
7880
"license": license,
7981
"extent": extent,
80-
"links": [],
82+
"links": links or [],
83+
**kwargs,
8184
}
8285
if cube_dimensions is not None:
8386
d["cube:dimensions"] = cube_dimensions
@@ -108,3 +111,19 @@ def catalog(
108111
if stac_extensions is not None:
109112
d["stac_extensions"] = stac_extensions
110113
return d
114+
115+
@classmethod
116+
def asset(
117+
cls,
118+
href: str = "https://stac.test/asset.tiff",
119+
type: str = "image/tiff; application=geotiff",
120+
roles: Optional[List[str]] = None,
121+
**kwargs,
122+
):
123+
d = {"href": href, **kwargs}
124+
if type:
125+
d["type"] = type
126+
if roles is not None:
127+
d["roles"] = roles
128+
129+
return d

openeo/utils/normalize.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Tuple, Union
1+
from typing import Callable, Iterable, Optional, Tuple, Union
22

33

44
def normalize_resample_resolution(
@@ -14,3 +14,15 @@ def normalize_resample_resolution(
1414
):
1515
return tuple(resolution)
1616
raise ValueError(f"Invalid resolution {resolution!r}")
17+
18+
19+
def unique(iterable, key: Optional[Callable] = None) -> Iterable:
20+
"""Deduplicate an iterable based on a key function."""
21+
# TODO: also support non-hashable items?
22+
seen = set()
23+
key = key or (lambda x: x)
24+
for x in iterable:
25+
k = key(x)
26+
if k not in seen:
27+
seen.add(k)
28+
yield x

0 commit comments

Comments
 (0)