@@ -30,8 +30,13 @@ class AssetDefinition:
3030
3131 properties : Dict [str , Any ]
3232
33- def __init__ (self , properties : Dict [str , Any ]) -> None :
33+ owner : Optional [pystac .Collection ]
34+
35+ def __init__ (
36+ self , properties : Dict [str , Any ], owner : Optional [pystac .Collection ] = None
37+ ) -> None :
3438 self .properties = properties
39+ self .owner = owner
3540
3641 def __eq__ (self , o : object ) -> bool :
3742 if not isinstance (o , AssetDefinition ):
@@ -107,6 +112,17 @@ def apply(
107112 self .description = description
108113 self .media_type = media_type
109114 self .roles = roles
115+ self .owner = None
116+
117+ def set_owner (self , obj : pystac .Collection ) -> None :
118+ """Sets the owning item of this AssetDefinition.
119+
120+ The owning item will be used to resolve relative HREFs of this asset.
121+
122+ Args:
123+ obj: The Collection that owns this asset.
124+ """
125+ self .owner = obj
110126
111127 @property
112128 def title (self ) -> Optional [str ]:
@@ -202,7 +218,7 @@ def item_assets(self) -> Dict[str, AssetDefinition]:
202218 result : Dict [str , Any ] = get_required (
203219 self .collection .extra_fields .get (ITEM_ASSETS_PROP ), self , ITEM_ASSETS_PROP
204220 )
205- return {k : AssetDefinition (v ) for k , v in result .items ()}
221+ return {k : AssetDefinition (v , self . collection ) for k , v in result .items ()}
206222
207223 @item_assets .setter
208224 def item_assets (self , v : Dict [str , AssetDefinition ]) -> None :
0 commit comments