File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ def get_bands(self, asset=None):
55
55
"""Gets an Item or an Asset bands.
56
56
57
57
If an Asset is supplied and the bands property exists on the Asset,
58
- returns the Asset's value. Otherwise returns the Item's value
58
+ returns the Asset's value. Otherwise returns the Item's value or
59
+ all the asset's eo bands
59
60
60
61
Returns:
61
62
List[Band]
@@ -65,6 +66,13 @@ def get_bands(self, asset=None):
65
66
else :
66
67
bands = self .item .properties .get ('eo:bands' )
67
68
69
+ # get assets with eo:bands even if not in item
70
+ if asset is None and bands is None :
71
+ bands = []
72
+ for (key , value ) in self .item .get_assets ().items ():
73
+ if 'eo:bands' in value .properties :
74
+ bands .extend (value .properties .get ('eo:bands' ))
75
+
68
76
if bands is not None :
69
77
bands = [Band (b ) for b in bands ]
70
78
Original file line number Diff line number Diff line change @@ -61,6 +61,10 @@ def test_asset_bands(self):
61
61
asset_bands = eo_item .ext .eo .get_bands (index_asset )
62
62
self .assertIs (None , asset_bands )
63
63
64
+ # No asset specified
65
+ asset_bands = eo_item .ext .eo .get_bands ()
66
+ self .assertIsNot (None , asset_bands )
67
+
64
68
# Set
65
69
b2_asset = eo_item .assets ['B2' ]
66
70
self .assertEqual (eo_item .ext .eo .get_bands (b2_asset )[0 ].name , "B2" )
You can’t perform that action at this time.
0 commit comments