Skip to content

Commit

Permalink
fix(backend): minor fixes to HTTPException on endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jul 4, 2024
1 parent 53e3412 commit 60c22f6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async def delete_one_project(db: Session, db_project: db_models.DbProject) -> No
log.info(f"Deleted project with ID: {project_id}")
except Exception as e:
log.exception(e)
raise HTTPException(e) from e
raise HTTPException(status_code=HTTPStatus.CONFLICT, detail=e) from e


async def partial_update_project_info(
Expand Down Expand Up @@ -395,7 +395,7 @@ async def create_tasks_from_geojson(
return True
except Exception as e:
log.exception(e)
raise HTTPException(e) from e
raise HTTPException(HTTPStatus.UNPROCESSABLE_ENTITY, detail=e) from e


async def preview_split_by_square(boundary: str, meters: int):
Expand Down 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

0 comments on commit 60c22f6

Please sign in to comment.