-
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
Merged
Merged
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
213fcec
initial changes for titiler pgstac v1 upgrade
smohiudd 6361c8d
format
smohiudd 12ec468
add add_search_list_route
smohiudd 47ffa3d
update titiler.core
smohiudd 9342294
fix jinja2 template
vincentsarago cdbaa28
fix list
vincentsarago fcf3fed
fix dependency
vincentsarago a5ecbcc
fix tests
vincentsarago cdd8986
change route prefix
smohiudd ddb3a5f
re-add colormap dependency import
smohiudd d455440
format
smohiudd d4578f1
update tests
smohiudd 139182e
format
smohiudd 2db7ac6
add collection endpoint
smohiudd 89f2d0f
change items endpoint
smohiudd 6fecd6c
update alt endpoint
smohiudd 5ba94f3
add endpoint tags
smohiudd dd96a7f
fix tests
smohiudd 7a6848e
format
smohiudd ab06ebb
update tags
smohiudd 4652db8
format, tag change
smohiudd 4e10923
not include alt schema
smohiudd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
from src.algorithms import PostProcessParams | ||
from src.alternate_reader import PgSTACReaderAlt | ||
from src.config import ApiSettings | ||
from src.dependencies import ColorMapParams, ItemPathParams | ||
from src.dependencies import ColorMapParams | ||
from src.extensions import stacViewerExtension | ||
from src.monitoring import LoggerRouteHandler, logger, metrics, tracer | ||
from src.version import __version__ as veda_raster_version | ||
|
@@ -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 CollectionIdParams, ItemIdParams, 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 | ||
|
@@ -64,61 +75,112 @@ async def lifespan(app: FastAPI): | |
add_exception_handlers(app, MOSAIC_STATUS_CODES) | ||
|
||
############################################################################### | ||
# /mosaic - PgSTAC Mosaic titiler endpoint | ||
# /searches - PgSTAC Mosaic titiler endpoint | ||
############################################################################### | ||
mosaic = MosaicTilerFactory( | ||
router_prefix="/mosaic", | ||
searches = MosaicTilerFactory( | ||
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(searches.router, prefix="/searches/{search_id}", tags=["STAC Search"]) | ||
|
||
# add /register endpoint | ||
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=[ | ||
searches.layer_dependency, | ||
searches.dataset_dependency, | ||
searches.pixel_selection_dependency, | ||
searches.process_dependency, | ||
searches.rescale_dependency, | ||
searches.colormap_dependency, | ||
searches.render_dependency, | ||
searches.pgstac_dependency, | ||
searches.reader_dependency, | ||
searches.backend_dependency, | ||
], | ||
tags=["STAC Search"] | ||
) | ||
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 | ||
if settings.enable_mosaic_search: | ||
add_search_list_route(app, prefix="/searches", tags=["STAC Search"]) | ||
|
||
############################################################################### | ||
# /stac - Custom STAC titiler endpoint | ||
# STAC COLLECTION Endpoints | ||
############################################################################### | ||
collection = MosaicTilerFactory( | ||
path_dependency=CollectionIdParams, | ||
optional_headers=optional_headers, | ||
router_prefix="/collections/{collection_id}", | ||
add_statistics=True, | ||
add_viewer=True, | ||
add_part=True, | ||
extensions=[ | ||
searchInfoExtension(), | ||
], | ||
) | ||
app.include_router( | ||
collection.router, tags=["STAC Collection"], prefix="/collections/{collection_id}" | ||
) | ||
|
||
|
||
############################################################################### | ||
# /collections/{collection_id}/items/{item_id} - Custom STAC titiler endpoint | ||
############################################################################### | ||
stac = MultiBaseTilerFactory( | ||
reader=PgSTACReader, | ||
path_dependency=ItemPathParams, | ||
path_dependency=ItemIdParams, | ||
optional_headers=optional_headers, | ||
router_prefix="/stac", | ||
router_prefix="/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.router, tags=["Items"], prefix="/stac") | ||
app.include_router( | ||
stac.router, | ||
tags=["STAC Item"], | ||
prefix="/collections/{collection_id}/items/{item_id}", | ||
) | ||
|
||
############################################################################### | ||
# /stac-alt - Custom STAC titiler endpoint for alternate asset locations | ||
# /alt/collections/{collection_id}/items/{item_id} - Custom STAC titiler endpoint for alternate asset locations | ||
############################################################################### | ||
stac_alt = MultiBaseTilerFactory( | ||
reader=PgSTACReaderAlt, | ||
path_dependency=ItemPathParams, | ||
path_dependency=ItemIdParams, | ||
optional_headers=optional_headers, | ||
router_prefix="/stac-alt", | ||
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="/stac-alt") | ||
app.include_router( | ||
stac_alt.router, | ||
tags=["Alt STAC Item"], | ||
anayeaye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
prefix="/alt/collections/{collection_id}/items/{item_id}", | ||
anayeaye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
############################################################################### | ||
# /cog - External Cloud Optimized GeoTIFF endpoints | ||
|
@@ -137,6 +199,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(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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