Skip to content

Commit 561f3fe

Browse files
author
Phil Varner
committed
refactor bbox handling
1 parent d74e386 commit 561f3fe

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ class CoreClient(AsyncBaseCoreClient):
5050
async def all_collections(self, **kwargs) -> Collections:
5151
"""Read all collections from the database."""
5252
base_url = str(kwargs["request"].base_url)
53-
serialized_collections = await self.database.get_all_collections(
54-
base_url=base_url
55-
)
53+
collection_list = await self.database.get_all_collections(base_url=base_url)
5654

5755
links = [
5856
{
@@ -71,10 +69,8 @@ async def all_collections(self, **kwargs) -> Collections:
7169
"href": urljoin(base_url, "collections"),
7270
},
7371
]
74-
collection_list = Collections(
75-
collections=serialized_collections or [], links=links
76-
)
77-
return collection_list
72+
73+
return Collections(collections=collection_list, links=links)
7874

7975
@overrides
8076
async def get_collection(self, collection_id: str, **kwargs) -> Collection:
@@ -91,22 +87,22 @@ async def item_collection(
9187
links = []
9288
base_url = str(kwargs["request"].base_url)
9389

94-
serialized_children, maybe_count = await self.database.get_collection_items(
90+
items, maybe_count = await self.database.get_collection_items(
9591
collection_id=collection_id, limit=limit, base_url=base_url
9692
)
9793

9894
context_obj = None
9995
if self.extension_is_enabled("ContextExtension"):
10096
context_obj = {
101-
"returned": len(serialized_children),
97+
"returned": len(items),
10298
"limit": limit,
10399
}
104100
if maybe_count is not None:
105101
context_obj["matched"] = maybe_count
106102

107103
return ItemCollection(
108104
type="FeatureCollection",
109-
features=serialized_children,
105+
features=items,
110106
links=links,
111107
context=context_obj,
112108
)

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def apply_bbox_filter(search: Search, bbox: List):
144144
"geometry": {
145145
"shape": {
146146
"type": "polygon",
147-
"coordinates": bbox2polygon(
148-
bbox[0], bbox[1], bbox[2], bbox[3]
149-
),
147+
"coordinates": bbox2polygon(*bbox),
150148
},
151149
"relation": "intersects",
152150
}

0 commit comments

Comments
 (0)