-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: titiler-pgstac v1 upgrade #398
Changes from 13 commits
213fcec
6361c8d
12ec468
47ffa3d
9342294
cdbaa28
fcf3fed
a5ecbcc
cdd8986
ddb3a5f
d455440
d4578f1
139182e
2db7ac6
89f2d0f
6fecd6c
5ba94f3
dd96a7f
7a6848e
ab06ebb
4652db8
4e10923
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,25 @@ | |
from starlette.requests import Request | ||
from starlette_cramjam.middleware import CompressionMiddleware | ||
from titiler.core.errors import DEFAULT_STATUS_CODES, add_exception_handlers | ||
from titiler.core.factory import MultiBaseTilerFactory, TilerFactory, TMSFactory | ||
from titiler.core.factory import ( | ||
ColorMapFactory, | ||
MultiBaseTilerFactory, | ||
TilerFactory, | ||
TMSFactory, | ||
) | ||
from titiler.core.middleware import CacheControlMiddleware | ||
from titiler.core.resources.enums import OptionalHeader | ||
from titiler.core.resources.responses import JSONResponse | ||
from titiler.extensions import cogValidateExtension, cogViewerExtension | ||
from titiler.mosaic.errors import MOSAIC_STATUS_CODES | ||
from titiler.pgstac.db import close_db_connection, connect_to_db | ||
from titiler.pgstac.factory import MosaicTilerFactory | ||
from titiler.pgstac.dependencies import SearchIdParams | ||
from titiler.pgstac.extensions import searchInfoExtension | ||
from titiler.pgstac.factory import ( | ||
MosaicTilerFactory, | ||
add_search_list_route, | ||
add_search_register_route, | ||
) | ||
from titiler.pgstac.reader import PgSTACReader | ||
|
||
logging.getLogger("botocore.credentials").disabled = True | ||
|
@@ -67,24 +78,36 @@ async def lifespan(app: FastAPI): | |
# /mosaic - PgSTAC Mosaic titiler endpoint | ||
############################################################################### | ||
mosaic = MosaicTilerFactory( | ||
router_prefix="/mosaic", | ||
router_prefix="/searches/{search_id}", | ||
path_dependency=SearchIdParams, | ||
optional_headers=optional_headers, | ||
environment_dependency=settings.get_gdal_config, | ||
process_dependency=PostProcessParams, | ||
router=APIRouter(route_class=LoggerRouteHandler), | ||
# add /list (default to False) | ||
add_mosaic_list=settings.enable_mosaic_search, | ||
# add /statistics [POST] (default to False) | ||
add_statistics=True, | ||
# add /map viewer (default to False) | ||
add_viewer=False, | ||
# add /bbox [GET] and /feature [POST] (default to False) | ||
add_part=True, | ||
colormap_dependency=ColorMapParams, | ||
extensions=[ | ||
searchInfoExtension(), | ||
], | ||
) | ||
app.include_router(mosaic.router, prefix="/searches/{search_id}", tags=["Mosaic"]) | ||
|
||
add_search_register_route( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add if settings.enable_mosaic_search:
add_search_register_route( |
||
app, | ||
prefix="/searches", | ||
# any dependency we want to validate | ||
# when creating the tilejson/map links | ||
tile_dependencies=[mosaic.process_dependency, mosaic.colormap_dependency], | ||
tags=["Mosaic"], | ||
) | ||
app.include_router(mosaic.router, prefix="/mosaic", tags=["Mosaic"]) | ||
# TODO | ||
# prefix will be replaced by `/mosaics/{search_id}` in titiler-pgstac 1.0.0 | ||
# add /list endpoint | ||
add_search_list_route(app, prefix="/searches", tags=["Mosaic"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the equivalent of the list registered mosaics endpoint that we were setting in the .env as
If so, do we want it always on now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the |
||
|
||
|
||
############################################################################### | ||
# /stac - Custom STAC titiler endpoint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from titiler.pgstac.dependencies import ItemIdParams
stac = MultiBaseTilerFactory(
reader=PgSTACReader,
path_dependency=ItemIdParams,
optional_headers=optional_headers,
router_prefix="/stac",
environment_dependency=settings.get_gdal_config,
router=APIRouter(route_class=LoggerRouteHandler),
extensions=[
stacViewerExtension(),
],
colormap_dependency=ColorMapParams,
)
app.include_router(stac.router, tags=["Items"], prefix="/collections/{collection_id}/items/{item_id}")
###############################################################################
# /alt - Custom STAC titiler endpoint for alternate asset locations
###############################################################################
stac_alt = MultiBaseTilerFactory(
reader=PgSTACReaderAlt,
path_dependency=ItemIdParams,
optional_headers=optional_headers,
router_prefix="/alt/collections/{collection_id}/items/{item_id}",
environment_dependency=settings.get_gdal_config,
router=APIRouter(route_class=LoggerRouteHandler),
extensions=[
stacViewerExtension(),
],
colormap_dependency=ColorMapParams,
)
app.include_router(stac_alt.router, tags=["Items"], prefix="/alt/collections/{collection_id}/items/{item_id}") |
||
|
@@ -137,6 +160,12 @@ async def lifespan(app: FastAPI): | |
|
||
app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"], prefix="/cog") | ||
|
||
############################################################################### | ||
# Colormaps endpoints | ||
############################################################################### | ||
cmaps = ColorMapFactory() | ||
app.include_router(cmaps.router, tags=["ColorMaps"]) | ||
|
||
|
||
@app.get("/healthz", description="Health Check", tags=["Health Check"]) | ||
def ping(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need
process_dependency
if we havetile_dependencies
below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smohiudd the process dependency is different from the tile_dependency. I see that we have custom post_process method, so if they are still used we should keep the process_dependency