Skip to content

Commit 2d58cf7

Browse files
authored
Merge branch 'main' into landingpage-update1
2 parents cecd114 + e3c07db commit 2d58cf7

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.github/workflows/tests/test_raster.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,16 @@ def test_item():
188188
in resp.json()["tiles"][0]
189189
)
190190
assert resp.json()["bounds"] == [-85.5501, 36.1749, -85.5249, 36.2001]
191+
192+
193+
def test_collections():
194+
"""test collection endpoints."""
195+
resp = httpx.get(
196+
f"{raster_endpoint}/collections",
197+
)
198+
assert resp.status_code == 200
199+
assert resp.headers["content-type"] == "application/json"
200+
201+
collections = resp.json()
202+
assert len(collections) == 1
203+
assert collections[0]["id"] == "noaa-emergency-response"

runtime/eoapi/raster/eoapi/raster/app.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from eoapi.raster.config import ApiSettings
1010
from fastapi import Depends, FastAPI, Query
1111
from psycopg import OperationalError
12+
from psycopg.rows import dict_row
1213
from psycopg_pool import PoolTimeout
1314
from starlette.middleware.cors import CORSMiddleware
1415
from starlette.requests import Request
@@ -88,11 +89,14 @@ async def lifespan(app: FastAPI):
8889
# MOSAIC Endpoints
8990
mosaic = MosaicTilerFactory(
9091
router_prefix="/mosaic",
92+
# add /statistics [POST]
9193
add_statistics=True,
9294
# add /map viewer
9395
add_viewer=True,
9496
# add /mosaic/list endpoint
9597
add_mosaic_list=True,
98+
# add `/bbox` and `/feature [POST]` endpoint
99+
add_part=False,
96100
)
97101

98102

@@ -115,9 +119,10 @@ async def mosaic_builder(request: Request):
115119
async def list_collection(request: Request):
116120
"""list collections."""
117121
with request.app.state.dbpool.connection() as conn:
118-
with conn.cursor() as cursor:
119-
cursor.execute("SELECT * FROM collections;")
120-
return [t[2] for t in cursor.fetchall() if t]
122+
with conn.cursor(row_factory=dict_row) as cursor:
123+
cursor.execute("SELECT * FROM pgstac.all_collections();")
124+
r = cursor.fetchone()
125+
return r.get("all_collections", [])
121126

122127

123128
app.include_router(mosaic.router, tags=["Mosaic"], prefix="/mosaic")

runtime/eoapi/raster/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
]
2020
dynamic = ["version"]
2121
dependencies = [
22-
"titiler.pgstac==0.7.0",
22+
"titiler.pgstac==0.8.0",
2323
"starlette-cramjam>=0.3,<0.4",
2424
"importlib_resources>=1.1.0;python_version<'3.9'",
2525
]

0 commit comments

Comments
 (0)