1
1
from enum import Enum
2
2
from 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
4
4
5
5
import pystac
6
6
from pystac .version import STACVersion
@@ -165,44 +165,6 @@ def __repr__(self) -> str:
165
165
)
166
166
167
167
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
-
206
168
def identify_stac_object_type (
207
169
json_dict : Dict [str , Any ]
208
170
) -> Optional ["STACObjectType_Type" ]:
@@ -227,15 +189,11 @@ def identify_stac_object_type(
227
189
228
190
obj_type = json_dict .get ("type" )
229
191
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
232
193
if "stac_version" in json_dict :
233
194
# Pre-1.0 STAC objects with 'type' == "Feature" are Items
234
195
if obj_type == "Feature" :
235
196
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
239
197
# Anything else with a 'type' field is not a STAC object
240
198
if obj_type is not None :
241
199
return None
@@ -246,16 +204,8 @@ def identify_stac_object_type(
246
204
# Everything else that has a stac_version is a Catalog
247
205
else :
248
206
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
259
209
260
210
261
211
def identify_stac_object (json_dict : Dict [str , Any ]) -> STACJSONDescription :
@@ -287,19 +237,7 @@ def identify_stac_object(json_dict: Dict[str, Any]) -> STACJSONDescription:
287
237
version_range .set_min (STACVersionID ("0.8.0" ))
288
238
289
239
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 = []
303
241
304
242
# Between 1.0.0-beta.2 and 1.0.0-RC1, STAC extensions changed from
305
243
# being split between 'common' and custom extensions, with common
0 commit comments