Skip to content

Commit

Permalink
Merge pull request #338 from hotosm/feat/reproject-orthophoto-to-epsg…
Browse files Browse the repository at this point in the history
…3857

fix: remove rio_tiler from project logic
  • Loading branch information
Pradip-p authored Nov 18, 2024
2 parents 64a9775 + f53e3a5 commit 71cf3fc
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/backend/app/projects/project_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from app.projects import project_schemas
from minio import S3Error
from psycopg.rows import dict_row
from rio_tiler.io import Reader
from rio_tiler.errors import TileOutsideBounds


async def get_centroids(db: Connection):
Expand Down Expand Up @@ -270,23 +268,3 @@ def get_project_info_from_s3(project_id: uuid.UUID, task_id: uuid.UUID):
except Exception as e:
log.exception(f"An error occurred while retrieving assets info: {e}")
raise HTTPException(status_code=500, detail=str(e))


def read_tile_from_cog(cog_path: str, x: int, y: int, z: int) -> bytes:
"""
Helper function to safely read a tile from a COG file.
This function is run in a separate thread.
"""
try:
# Open the COG file safely and fetch the specified tile
with Reader(cog_path) as tiff:
img = tiff.tile(int(x), int(y), int(z), tilesize=256)
tile = img.render() # Render the tile as a PNG byte array
return tile

except TileOutsideBounds:
# Reraise to handle in async function
raise
except Exception as e:
# Catch any unforeseen errors and reraise as needed
raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")

0 comments on commit 71cf3fc

Please sign in to comment.