Skip to content
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

Add tiles_info endpoint #526

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions app/routes/assets/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

# from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, Path, status
from fastapi.responses import ORJSONResponse
from starlette.responses import JSONResponse
from starlette.responses import JSONResponse, RedirectResponse

from app.models.pydantic.responses import Response
from app.settings.globals import API_URL
from ..datasets.downloads import _get_presigned_url

from ...authentication.token import is_admin
from ...crud import assets
from ...crud import metadata as metadata_crud
from ...crud import tasks
Expand Down Expand Up @@ -67,7 +67,7 @@
delete_static_vector_tile_cache_assets,
)
from ...utils.paginate import paginate_collection
from ...utils.path import infer_srid_from_grid
from ...utils.path import infer_srid_from_grid, split_s3_path
from ..assets import asset_response
from ..tasks import paginated_tasks_response, tasks_response

Expand Down Expand Up @@ -310,6 +310,28 @@ async def get_extent(asset_id: UUID = Path(...)):
return ExtentResponse(data=extent)


@router.get(
"/{asset_id}/tiles_info",
response_class=RedirectResponse,
tags=["Assets"],
status_code=307,
)
async def get_tiles_info(asset_id: UUID = Path(...)):
asset: ORMAsset = await assets.get_asset(asset_id)

if asset.asset_type != AssetType.raster_tile_set:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Tiles information only available for raster tile sets"
)

bucket, asset_key = split_s3_path(asset.asset_uri)
tiles_geojson_key = asset_key.replace("{tile_id}.tif", "tiles.geojson")
presigned_url = await _get_presigned_url(bucket, tiles_geojson_key)

return RedirectResponse(url=presigned_url)


@router.get(
"/{asset_id}/stats",
response_class=ORJSONResponse,
Expand Down
Loading