Skip to content

Commit efe6968

Browse files
committed
update es serializers
1 parent e7664bc commit efe6968

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/serializers.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ 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"] if "stac_extensions" in item else [],
42+
id=item_id,
43+
collection=item["collection"] if "collection" in item else "",
44+
geometry=item["geometry"] if "geometry" in item else {},
45+
bbox=item["bbox"] if "bbox" in item else [],
46+
properties=item["properties"] if "properties" in item else {},
47+
links=item_links if "links" in item else [],
48+
assets=item["assets"] if "assets" in item else {},
4949
)
5050

5151

@@ -63,20 +63,17 @@ def db_to_stac(cls, collection: dict, base_url: str) -> stac_types.Collection:
6363
if original_links:
6464
collection_links += resolve_links(original_links, base_url)
6565

66-
if "providers" not in collection:
67-
collection["providers"] = {}
68-
6966
return stac_types.Collection(
7067
type="Collection",
7168
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"],
69+
stac_extensions=collection["stac_extensions"] if "stac_extensions" in collection else [],
70+
stac_version=collection["stac_version"] if "stac_version" in collection else "",
71+
title=collection["title"] if "title" in collection else "",
72+
description=collection["description"] if "description" in collection else "",
73+
keywords=collection["keywords"] if "keywords" in collection else [],
74+
license=collection["license"] if "license" in collection else "",
75+
providers=collection["providers"] if "providers" in collection else {},
76+
summaries=collection["summaries"] if "summaries" in collection else {},
77+
extent=collection["extent"] if "extent" in collection else {},
8178
links=collection_links,
8279
)

0 commit comments

Comments
 (0)