11from enum import Enum
22from functools import total_ordering
3- from typing import Any , Dict , List , Optional , Set , TYPE_CHECKING , Union , cast
3+ from typing import Any , Dict , Optional , Set , TYPE_CHECKING , Union
44
55import pystac
66from pystac .version import STACVersion
@@ -165,44 +165,6 @@ def __repr__(self) -> str:
165165 )
166166
167167
168- def _identify_stac_extensions (
169- object_type : str , d : Dict [str , Any ], version_range : STACVersionRange
170- ) -> List [str ]:
171- """Identifies extensions for STAC Objects that don't list their
172- extensions in a 'stac_extensions' property.
173-
174- Returns a list of stac_extensions. May mutate the version_range to update
175- min or max version.
176- """
177- stac_extensions : Set [str ] = set ([])
178-
179- # assets (collection assets)
180-
181- if object_type == pystac .STACObjectType .ITEMCOLLECTION :
182- if "assets" in d :
183- stac_extensions .add ("assets" )
184- version_range .set_min (STACVersionID ("0.8.0" ))
185-
186- # checksum
187- if "links" in d :
188- for link in d ["links" ]:
189- link_props = cast (Dict [str , Any ], link ).keys ()
190-
191- if any (prop .startswith ("checksum:" ) for prop in link_props ):
192- stac_extensions .add (OldExtensionShortIDs .CHECKSUM .value )
193- version_range .set_min (STACVersionID ("0.6.2" ))
194-
195- # Single File STAC
196- if object_type == pystac .STACObjectType .ITEMCOLLECTION :
197- if "collections" in d :
198- stac_extensions .add (OldExtensionShortIDs .SINGLE_FILE_STAC .value )
199- version_range .set_min (STACVersionID ("0.8.0" ))
200- if "stac_extensions" not in d :
201- version_range .set_max (STACVersionID ("0.8.1" ))
202-
203- return list (stac_extensions )
204-
205-
206168def identify_stac_object_type (
207169 json_dict : Dict [str , Any ]
208170) -> Optional ["STACObjectType_Type" ]:
@@ -227,15 +189,11 @@ def identify_stac_object_type(
227189
228190 obj_type = json_dict .get ("type" )
229191
230- # For pre-1.0 objects for version 0.8.* or later 'stac_version' must be present,
231- # except for in ItemCollections (which are handled in the else clause)
192+ # For pre-1.0 objects for version 0.8.* or later 'stac_version' must be present
232193 if "stac_version" in json_dict :
233194 # Pre-1.0 STAC objects with 'type' == "Feature" are Items
234195 if obj_type == "Feature" :
235196 return pystac .STACObjectType .ITEM
236- # Pre-1.0 STAC objects with 'type' == "FeatureCollection" are ItemCollections
237- if obj_type == "FeatureCollection" :
238- return pystac .STACObjectType .ITEMCOLLECTION
239197 # Anything else with a 'type' field is not a STAC object
240198 if obj_type is not None :
241199 return None
@@ -246,16 +204,8 @@ def identify_stac_object_type(
246204 # Everything else that has a stac_version is a Catalog
247205 else :
248206 return pystac .STACObjectType .CATALOG
249- else :
250- # Prior to STAC 0.9 ItemCollections did not have a stac_version field and could
251- # only be identified by the fact that all of their 'features' are STAC Items
252- if obj_type == "FeatureCollection" :
253- if all (
254- identify_stac_object_type (feat ) == pystac .STACObjectType .ITEM
255- for feat in json_dict .get ("features" , [])
256- ):
257- return pystac .STACObjectType .ITEMCOLLECTION
258- return None
207+
208+ return None
259209
260210
261211def identify_stac_object (json_dict : Dict [str , Any ]) -> STACJSONDescription :
@@ -287,19 +237,7 @@ def identify_stac_object(json_dict: Dict[str, Any]) -> STACJSONDescription:
287237 version_range .set_min (STACVersionID ("0.8.0" ))
288238
289239 if stac_extensions is None :
290- # If this is post-0.8, we can assume there are no extensions
291- # if the stac_extensions property doesn't exist for everything
292- # but ItemCollection (except after 0.9.0, when ItemCollection also got
293- # the stac_extensions property).
294- if (
295- object_type == pystac .STACObjectType .ITEMCOLLECTION
296- and not version_range .is_later_than ("0.8.1" )
297- ):
298- stac_extensions = _identify_stac_extensions (
299- object_type , json_dict , version_range
300- )
301- else :
302- stac_extensions = []
240+ stac_extensions = []
303241
304242 # Between 1.0.0-beta.2 and 1.0.0-RC1, STAC extensions changed from
305243 # being split between 'common' and custom extensions, with common
0 commit comments