-
Notifications
You must be signed in to change notification settings - Fork 29
update titiler/titiler-pgstac #252
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
Draft
vincentsarago
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
developmentseed:feature/update-titiler-version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
from dataclasses import dataclass, field | ||
from typing import Annotated, List, Literal, Optional | ||
|
||
from fastapi import APIRouter, Depends, FastAPI, Query, Request, Response | ||
from fastapi import APIRouter, Depends, FastAPI, Query, Request, Response, Path | ||
from fastapi.responses import ORJSONResponse | ||
from psycopg_pool import ConnectionPool | ||
from pydantic import Field | ||
from titiler.core import dependencies | ||
from titiler.core.dependencies import ColorFormulaParams | ||
from titiler.core.factory import img_endpoint_params | ||
from titiler.core.resources.enums import ImageType | ||
from titiler.pgstac.dependencies import SearchIdParams, TmsTileParams | ||
from titiler.pgstac.dependencies import SearchIdParams | ||
from titiler.pgstac.extensions import searchInfoExtension | ||
from titiler.pgstac.factory import MosaicTilerFactory | ||
|
||
|
@@ -40,7 +40,7 @@ def __init__(self, request: Request): | |
|
||
|
||
pgstac_mosaic_factory = MosaicTilerFactory( | ||
reader=PGSTACBackend, | ||
backend=PGSTACBackend, | ||
path_dependency=SearchIdParams, | ||
colormap_dependency=PCColorMapParams, | ||
layer_dependency=AssetsBidxExprParams, | ||
|
@@ -86,7 +86,7 @@ def mosaic_info( | |
|
||
legacy_mosaic_router = APIRouter() | ||
|
||
|
||
# Compat with titiler-pgstac<0.3.0, (`/tiles/{search_id}/...` was renamed `/{search_id}/tiles/...`) | ||
@legacy_mosaic_router.get("/tiles/{search_id}/{z}/{x}/{y}", **img_endpoint_params) | ||
@legacy_mosaic_router.get( | ||
"/tiles/{search_id}/{z}/{x}/{y}.{format}", **img_endpoint_params | ||
|
@@ -115,57 +115,74 @@ def mosaic_info( | |
def tile_routes( # type: ignore | ||
request: Request, | ||
search_id=Depends(pgstac_mosaic_factory.path_dependency), | ||
tile=Depends(TmsTileParams), | ||
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.
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. Not a problem! |
||
z: Annotated[ | ||
int, | ||
Path( | ||
description="Identifier (Z) selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile.", | ||
), | ||
], | ||
x: Annotated[ | ||
int, | ||
Path( | ||
description="Column (X) index of the tile on the selected TileMatrix. It cannot exceed the MatrixHeight-1 for the selected TileMatrix.", | ||
), | ||
], | ||
y: Annotated[ | ||
int, | ||
Path( | ||
description="Row (Y) index of the tile on the selected TileMatrix. It cannot exceed the MatrixWidth-1 for the selected TileMatrix.", | ||
), | ||
], | ||
tileMatrixSetId: Annotated[ # type: ignore | ||
Literal[tuple(pgstac_mosaic_factory.supported_tms.list())], | ||
f"Identifier selecting one of the TileMatrixSetId supported (default: '{pgstac_mosaic_factory.default_tms}')", # noqa: E501,F722 | ||
] = pgstac_mosaic_factory.default_tms, | ||
f"Identifier selecting one of the TileMatrixSetId supported (default: 'WebMercatorQuad')", # noqa: E501,F722 | ||
] = "WebMercatorQuad", | ||
scale: Annotated[ # type: ignore | ||
Optional[Annotated[int, Field(gt=0, le=4)]], | ||
"Tile size scale. 1=256x256, 2=512x512...", # noqa: E501,F722 | ||
] = None, | ||
format: Annotated[ | ||
Optional[ImageType], | ||
"Default will be automatically defined if the output image needs a mask (png) or not (jpeg).", # noqa: E501,F722 | ||
Field( | ||
description="Default will be automatically defined if the output image needs a mask (png) or not (jpeg)." | ||
), | ||
] = None, | ||
backend_params=Depends(pgstac_mosaic_factory.backend_dependency), | ||
reader_params=Depends(pgstac_mosaic_factory.reader_dependency), | ||
assets_accessor_params=Depends(pgstac_mosaic_factory.assets_accessor_dependency), | ||
layer_params=Depends(pgstac_mosaic_factory.layer_dependency), | ||
dataset_params=Depends(pgstac_mosaic_factory.dataset_dependency), | ||
pixel_selection=Depends(pgstac_mosaic_factory.pixel_selection_dependency), | ||
tile_params=Depends(pgstac_mosaic_factory.tile_dependency), | ||
post_process=Depends(pgstac_mosaic_factory.process_dependency), | ||
rescale=Depends(pgstac_mosaic_factory.rescale_dependency), | ||
color_formula=Depends(ColorFormulaParams), | ||
colormap=Depends(pgstac_mosaic_factory.colormap_dependency), | ||
render_params=Depends(pgstac_mosaic_factory.render_dependency), | ||
pgstac_params=Depends(pgstac_mosaic_factory.pgstac_dependency), | ||
backend_params=Depends(pgstac_mosaic_factory.backend_dependency), | ||
reader_params=Depends(pgstac_mosaic_factory.reader_dependency), | ||
env=Depends(pgstac_mosaic_factory.environment_dependency), | ||
) -> Response: | ||
"""Create map tile.""" | ||
endpoint = get_endpoint_function( | ||
pgstac_mosaic_factory.router, | ||
path="/tiles/{z}/{x}/{y}", | ||
path="/tiles/{tileMatrixSetId}/{z}/{x}/{y}", | ||
method=request.method, | ||
) | ||
result = endpoint( | ||
search_id=search_id, | ||
tile=tile, | ||
z=z, | ||
x=x, | ||
y=y, | ||
tileMatrixSetId=tileMatrixSetId, | ||
scale=scale, | ||
format=format, | ||
tile_params=tile_params, | ||
backend_params=backend_params, | ||
reader_params=reader_params, | ||
assets_accessor_params=assets_accessor_params, | ||
layer_params=layer_params, | ||
dataset_params=dataset_params, | ||
pixel_selection=pixel_selection, | ||
tile_params=tile_params, | ||
post_process=post_process, | ||
rescale=rescale, | ||
color_formula=color_formula, | ||
colormap=colormap, | ||
render_params=render_params, | ||
pgstac_params=pgstac_params, | ||
backend_params=backend_params, | ||
reader_params=reader_params, | ||
env=env, | ||
) | ||
return result |
Oops, something went wrong.
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.
I've added this because I thought we needed
default
WebMercatorQuad tilematrixset back.We can remove if not needed
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.
Let's keep it, I see in our logs that we do have callers that request tiles without a TMS in the path.
For others, you can verify with this query in
pc-api-appinsights
: