@@ -37,15 +37,17 @@ def db_to_stac(cls, item: dict, base_url: str) -> stac_types.Item:
37
37
38
38
return stac_types .Item (
39
39
type = "Feature" ,
40
- stac_version = item ["stac_version" ],
41
- stac_extensions = item ["stac_extensions" ] or [],
42
- id = item ["id" ],
43
- collection = item ["collection" ],
44
- geometry = item ["geometry" ],
45
- bbox = item ["bbox" ],
46
- properties = item ["properties" ],
47
- links = item_links ,
48
- assets = item ["assets" ],
40
+ stac_version = item ["stac_version" ] if "stac_version" in item else "" ,
41
+ stac_extensions = item ["stac_extensions" ]
42
+ if "stac_extensions" in item
43
+ else [],
44
+ id = item_id ,
45
+ collection = item ["collection" ] if "collection" in item else "" ,
46
+ geometry = item ["geometry" ] if "geometry" in item else {},
47
+ bbox = item ["bbox" ] if "bbox" in item else [],
48
+ properties = item ["properties" ] if "properties" in item else {},
49
+ links = item_links if "links" in item else [],
50
+ assets = item ["assets" ] if "assets" in item else {},
49
51
)
50
52
51
53
@@ -63,20 +65,23 @@ def db_to_stac(cls, collection: dict, base_url: str) -> stac_types.Collection:
63
65
if original_links :
64
66
collection_links += resolve_links (original_links , base_url )
65
67
66
- if "providers" not in collection :
67
- collection ["providers" ] = {}
68
-
69
68
return stac_types .Collection (
70
69
type = "Collection" ,
71
70
id = collection ["id" ],
72
- stac_extensions = collection ["stac_extensions" ] or [],
73
- stac_version = collection ["stac_version" ],
74
- title = collection ["title" ],
75
- description = collection ["description" ],
76
- keywords = collection ["keywords" ],
77
- license = collection ["license" ],
78
- providers = collection ["providers" ],
79
- summaries = collection ["summaries" ],
80
- extent = collection ["extent" ],
71
+ stac_extensions = collection ["stac_extensions" ]
72
+ if "stac_extensions" in collection
73
+ else [],
74
+ stac_version = collection ["stac_version" ]
75
+ if "stac_version" in collection
76
+ else "" ,
77
+ title = collection ["title" ] if "title" in collection else "" ,
78
+ description = collection ["description" ]
79
+ if "description" in collection
80
+ else "" ,
81
+ keywords = collection ["keywords" ] if "keywords" in collection else [],
82
+ license = collection ["license" ] if "license" in collection else "" ,
83
+ providers = collection ["providers" ] if "providers" in collection else {},
84
+ summaries = collection ["summaries" ] if "summaries" in collection else {},
85
+ extent = collection ["extent" ] if "extent" in collection else {},
81
86
links = collection_links ,
82
87
)
0 commit comments