Skip to content

Commit 9b6ae7e

Browse files
jonas-hurstgadomski
authored andcommitted
Add MLM extension (stac-utils#1542)
* added missing Classification parameter title * added changes to changelog * added missing parameters to test_classification_object: title, nodata, percentage, count * added ml extension * added stac:mlm extension tests * added collection and asset extension * removed TODO * added documentation * added docstring to classes * renamed asset extension classes * added mlm extension classes * added mlm extension * removed todos * added extension migration * removed useless code * fixed docstrings * fixed __eq__ NotImplemented * fixed repr strings * improved test coverage * improved test coverage * changed exceptions * fixed docstring * Update CHANGELOG.md Co-authored-by: Pete Gadomski <[email protected]> * fixed typo Co-authored-by: Pete Gadomski <[email protected]> * fixed typo Co-authored-by: Pete Gadomski <[email protected]> * fixed typo Co-authored-by: Pete Gadomski <[email protected]> * fixed typo Co-authored-by: Pete Gadomski <[email protected]> * fixed typo Co-authored-by: Pete Gadomski <[email protected]> * line break to satisfy line length requirement * fixed typo in ENTRYPOINT_ASSET_PROP * fixed typo in COMPILE_METHOD_ASSET_PROP * removed dummy docstring * fixed Enum tuples * added mlm to CollectionExt * added mlm to Asset and ItemAssetDefinition mlm accessor * Update CHANGELOG.md --------- Co-authored-by: Pete Gadomski <[email protected]>
1 parent 5b47592 commit 9b6ae7e

File tree

12 files changed

+5580
-0
lines changed

12 files changed

+5580
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- `Collection.from_items` for creating a `pystac.Collection` from an `ItemCollection` ([#1522](https://github.com/stac-utils/pystac/pull/1522))
8+
- `extensions.mlm` for supporting the [MLM](https://github.com/stac-extensions/mlm) extension ([#1542](https://github.com/stac-utils/pystac/pull/1542))
89

910
### Fixed
1011

docs/api/extensions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pystac.extensions
2020
grid.GridExtension
2121
item_assets.ItemAssetsExtension
2222
mgrs.MgrsExtension
23+
mlm.MLMExtension
24+
mlm.AssetGeneralMLMExtension
25+
mlm.AssetDetailedMLMExtension
2326
pointcloud.PointcloudExtension
2427
projection.ProjectionExtension
2528
raster.RasterExtension

docs/api/extensions/mlm.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pystac.extensions.mlm
2+
============================
3+
4+
.. automodule:: pystac.extensions.mlm
5+
:members:
6+
:inherited-members: StringEnum, Generic, PropertiesExtension, ExtensionManagementMixin
7+
:undoc-members:
8+

pystac/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
warnings.filterwarnings("ignore", category=DeprecationWarning)
101101
import pystac.extensions.label
102102
import pystac.extensions.mgrs
103+
import pystac.extensions.mlm
103104
import pystac.extensions.pointcloud
104105
import pystac.extensions.projection
105106
import pystac.extensions.raster
@@ -124,6 +125,7 @@
124125
pystac.extensions.item_assets.ITEM_ASSETS_EXTENSION_HOOKS,
125126
pystac.extensions.label.LABEL_EXTENSION_HOOKS,
126127
pystac.extensions.mgrs.MGRS_EXTENSION_HOOKS,
128+
pystac.extensions.mlm.MLM_EXTENSION_HOOKS,
127129
pystac.extensions.pointcloud.POINTCLOUD_EXTENSION_HOOKS,
128130
pystac.extensions.projection.PROJECTION_EXTENSION_HOOKS,
129131
pystac.extensions.raster.RASTER_EXTENSION_HOOKS,

pystac/extensions/ext.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
from pystac.extensions.grid import GridExtension
2020
from pystac.extensions.item_assets import ItemAssetsExtension
2121
from pystac.extensions.mgrs import MgrsExtension
22+
from pystac.extensions.mlm import (
23+
AssetDetailedMLMExtension,
24+
AssetGeneralMLMExtension,
25+
MLMExtension,
26+
)
2227
from pystac.extensions.pointcloud import PointcloudExtension
2328
from pystac.extensions.projection import ProjectionExtension
2429
from pystac.extensions.raster import RasterExtension
@@ -49,6 +54,7 @@
4954
"grid",
5055
"item_assets",
5156
"mgrs",
57+
"mlm",
5258
"pc",
5359
"proj",
5460
"raster",
@@ -73,6 +79,7 @@
7379
GridExtension.name: GridExtension,
7480
ItemAssetsExtension.name: ItemAssetsExtension,
7581
MgrsExtension.name: MgrsExtension,
82+
MLMExtension.name: MLMExtension,
7683
PointcloudExtension.name: PointcloudExtension,
7784
ProjectionExtension.name: ProjectionExtension,
7885
RasterExtension.name: RasterExtension,
@@ -156,6 +163,10 @@ def cube(self) -> DatacubeExtension[Collection]:
156163
def item_assets(self) -> dict[str, ItemAssetDefinition]:
157164
return ItemAssetsExtension.ext(self.stac_object).item_assets
158165

166+
@property
167+
def mlm(self) -> MLMExtension[Collection]:
168+
return MLMExtension.ext(self.stac_object)
169+
159170
@property
160171
def render(self) -> dict[str, Render]:
161172
return RenderExtension.ext(self.stac_object).renders
@@ -232,6 +243,10 @@ def grid(self) -> GridExtension:
232243
def mgrs(self) -> MgrsExtension:
233244
return MgrsExtension.ext(self.stac_object)
234245

246+
@property
247+
def mlm(self) -> MLMExtension[Item]:
248+
return MLMExtension.ext(self.stac_object)
249+
235250
@property
236251
def pc(self) -> PointcloudExtension[Item]:
237252
return PointcloudExtension.ext(self.stac_object)
@@ -404,6 +419,13 @@ class AssetExt(_AssetExt[Asset]):
404419
def file(self) -> FileExtension[Asset]:
405420
return FileExtension.ext(self.stac_object)
406421

422+
@property
423+
def mlm(self) -> AssetGeneralMLMExtension[Asset] | AssetDetailedMLMExtension:
424+
if "mlm:name" in self.stac_object.extra_fields:
425+
return AssetDetailedMLMExtension.ext(self.stac_object)
426+
else:
427+
return AssetGeneralMLMExtension.ext(self.stac_object)
428+
407429
@property
408430
def timestamps(self) -> TimestampsExtension[Asset]:
409431
return TimestampsExtension.ext(self.stac_object)
@@ -425,6 +447,10 @@ class ItemAssetExt(_AssetExt[ItemAssetDefinition]):
425447

426448
stac_object: ItemAssetDefinition
427449

450+
@property
451+
def mlm(self) -> MLMExtension[ItemAssetDefinition]:
452+
return MLMExtension.ext(self.stac_object)
453+
428454

429455
@dataclass
430456
class LinkExt(_AssetsExt[Link]):

0 commit comments

Comments
 (0)