Skip to content

Commit

Permalink
fix(hotfix): download of basemaps in ui, max zoom level 22 used for tms
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jul 4, 2024
1 parent 80289b6 commit 16c9303
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
17 changes: 12 additions & 5 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ def get_project_tiles(
background_task_id: uuid.UUID,
source: str,
output_format: str = "mbtiles",
tms: str = None,
tms: Optional[str] = None,
):
"""Get the tiles for a project.
Expand All @@ -1381,7 +1381,12 @@ def get_project_tiles(
Other options: "pmtiles", "sqlite3".
tms (str, optional): Default None. Custom TMS provider URL.
"""
zooms = "12-19"
# TODO update this for user input or automatic
# maxzoom can be determined from OAM: https://tiles.openaerialmap.org/663
# c76196049ef00013b8494/0/663c76196049ef00013b8495
# TODO xy should also be user configurable
# NOTE mbtile max supported zoom level is 22 (in GDAL at least)
zooms = "12-22" if tms else "12-19"
tiles_dir = f"{TILESDIR}/{project_id}"
outfile = f"{tiles_dir}/{project_id}_{source}tiles.{output_format}"

Expand Down Expand Up @@ -1415,7 +1420,9 @@ def get_project_tiles(
if project_bbox:
min_lon, min_lat, max_lon, max_lat = project_bbox
else:
log.error(f"Failed to get bbox from project: {project_id}")
msg = f"Failed to get bbox from project: {project_id}"
log.error(msg)
raise HTTPException(status_code=HTTPStatus.UNPROCESSABLE_ENTITY, detail=msg)

log.debug(
"Creating basemap with params: "
Expand All @@ -1424,7 +1431,7 @@ def get_project_tiles(
f"zooms={zooms} | "
f"outdir={tiles_dir} | "
f"source={source} | "
f"xy={False} | "
f"xy={True if tms else False} | "
f"tms={tms}"
)

Expand All @@ -1434,7 +1441,7 @@ def get_project_tiles(
zooms=zooms,
outdir=tiles_dir,
source=source,
xy=False,
xy=True if tms else False,
tms=tms,
)

Expand Down
2 changes: 1 addition & 1 deletion src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async def download_tiles(
return FileResponse(
dbtile_obj.path,
headers={
"Content-Disposition": f'attachment; filename="{filename}"',
"Content-Disposition": f"attachment; filename={filename}",
"Content-Type": tiles_mime_type,
},
)
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/src/api/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ export const DownloadTile = (url, payload, toOpfs = false) => {
return;
}

const filename = response.headers['Content-Disposition'].split('filename=')[1];
const filename = response.headers['content-disposition'].split('filename=')[1];
console.log(filename)
// Create Blob from ArrayBuffer
const blob = new Blob([tileData], { type: response.headers['Content-Type'] });
const blob = new Blob([tileData], { type: response.headers['content-type'] });
const downloadUrl = URL.createObjectURL(blob);

const a = document.createElement('a');
Expand Down

0 comments on commit 16c9303

Please sign in to comment.