@@ -37,15 +37,17 @@ def db_to_stac(cls, item: dict, base_url: str) -> stac_types.Item:
3737
3838 return stac_types .Item (
3939 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 {},
4951 )
5052
5153
@@ -63,20 +65,23 @@ def db_to_stac(cls, collection: dict, base_url: str) -> stac_types.Collection:
6365 if original_links :
6466 collection_links += resolve_links (original_links , base_url )
6567
66- if "providers" not in collection :
67- collection ["providers" ] = {}
68-
6968 return stac_types .Collection (
7069 type = "Collection" ,
7170 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 {},
8186 links = collection_links ,
8287 )
0 commit comments