From 9de0b423e283c3a790b8088e936cde0c0e89a8e6 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Mon, 18 Dec 2023 09:45:35 -0500 Subject: [PATCH] Add back in 'dodgy check' for older versions of pystac --- odc/stac/_mdtools.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/odc/stac/_mdtools.py b/odc/stac/_mdtools.py index b9d977d..d2c17ea 100644 --- a/odc/stac/_mdtools.py +++ b/odc/stac/_mdtools.py @@ -156,7 +156,14 @@ def has_proj_ext(item: Union[pystac.item.Item, pystac.collection.Collection]) -> :returns: ``True`` if PROJ extension is enabled :returns: ``False`` if no PROJ extension was found """ - return ProjectionExtension.has_extension(item) + if ProjectionExtension.has_extension(item): + return True + # can remove this block once pystac 1.9.0 is the min supported version + else: + return any( + ext_name.startswith("https://stac-extensions.github.io/projection/") + for ext_name in item.stac_extensions + ) def has_raster_ext(item: Union[pystac.item.Item, pystac.collection.Collection]) -> bool: @@ -166,7 +173,14 @@ def has_raster_ext(item: Union[pystac.item.Item, pystac.collection.Collection]) :returns: ``True`` if Raster extension is enabled :returns: ``False`` if no Raster extension was found """ - return RasterExtension.has_extension(item) + if RasterExtension.has_extension(item): + return True + # can remove this block once pystac 1.9.0 is the min supported version + else: + return any( + ext_name.startswith("https://stac-extensions.github.io/raster/") + for ext_name in item.stac_extensions + ) def has_proj_data(asset: pystac.asset.Asset) -> bool: