Skip to content

Commit

Permalink
Merge pull request #11 from UNDP-Data/feature/add-mosaicjson-create-post
Browse files Browse the repository at this point in the history
added /mosaicjson/create POST method
  • Loading branch information
JinIgarashi authored Oct 19, 2022
2 parents 2f5d7c1 + ed0874e commit 6f64b53
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions titiler/app/wmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from titiler.core.resources.responses import JSONResponse
from starlette.responses import HTMLResponse

from typing import Any, Dict, List, Type, Optional
from typing import Any, Dict, List, Type, Optional, Union
from pydantic import BaseModel

import attr
from morecantile import TileMatrixSet
Expand Down Expand Up @@ -137,6 +138,32 @@ def MultibandDatasetPathParams(url: List = Query(..., description="Dataset URL")
path_dependency=MultibandDatasetPathParams
)

class MosaicJsonCreateItem(BaseModel):
url: List[str] = Query(..., description="Dataset URL")
minzoom: int = 0
maxzoom: int = 22
attribution:str = None

@mosaic.router.post(
"/create",
response_model=MosaicJSON,
response_model_exclude_none=True,
response_class=JSONResponse,
responses={
200: {"description": "Return a MosaicJSON from multiple COGs."}},
)

def create_mosaicJSON_post(payload : MosaicJsonCreateItem):
url = MultibandDatasetPathParams(payload.url)
minzoom = payload.minzoom
maxzoom = payload.minzoom
attribution = payload.attribution

mosaicjson = MosaicJSON.from_urls(urls=url, minzoom=minzoom, maxzoom=maxzoom, )
if attribution is not None:
mosaicjson.attribution = attribution
return mosaicjson

@mosaic.router.get(
"/create",
response_model=MosaicJSON,
Expand All @@ -146,7 +173,7 @@ def MultibandDatasetPathParams(url: List = Query(..., description="Dataset URL")
200: {"description": "Return a MosaicJSON from multiple COGs."}},
)

def create_mosaicJSON(
def create_mosaicJSON_get(
url=Depends(MultibandDatasetPathParams),
minzoom :Optional[int]=0,
maxzoom :Optional[int]= 22,
Expand Down

0 comments on commit 6f64b53

Please sign in to comment.