From f08399f1534312a989711b630af9ff7a8e5c7d65 Mon Sep 17 00:00:00 2001 From: sujanadh Date: Wed, 8 Nov 2023 16:57:14 +0545 Subject: [PATCH 1/2] task wise mbtile generation --- src/backend/app/projects/project_crud.py | 22 +++++++++++++--------- src/backend/app/projects/project_routes.py | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index f73a664867..5706cf6b48 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -2328,6 +2328,7 @@ def get_project_tiles( background_task_id: uuid.UUID, source: str, output_format: str = "mbtiles", + task_id: int = None, tms: str = None, ): """Get the tiles for a project. @@ -2356,24 +2357,27 @@ def get_project_tiles( try: db.add(tile_path_instance) db.commit() - - # Project Outline - log.debug(f"Getting bbox for project: {project_id}") + + get_id = task_id or project_id + entity = "tasks" if task_id else "projects" + + # Project/task Outline + log.debug(f"Getting bbox : {get_id}") query = text( f"""SELECT ST_XMin(ST_Envelope(outline)) AS min_lon, ST_YMin(ST_Envelope(outline)) AS min_lat, ST_XMax(ST_Envelope(outline)) AS max_lon, ST_YMax(ST_Envelope(outline)) AS max_lat - FROM projects - WHERE id = {project_id};""" + FROM {entity} + WHERE id = {get_id};""" ) result = db.execute(query) - project_bbox = result.fetchone() - log.debug(f"Extracted project bbox: {project_bbox}") + bbox = result.fetchone() + log.debug(f"Extracted bbox: {bbox}") - if project_bbox: - min_lon, min_lat, max_lon, max_lat = project_bbox + if bbox: + min_lon, min_lat, max_lon, max_lat = bbox else: log.error(f"Failed to get bbox from project: {project_id}") diff --git a/src/backend/app/projects/project_routes.py b/src/backend/app/projects/project_routes.py index a8a3401965..4134673edf 100644 --- a/src/backend/app/projects/project_routes.py +++ b/src/backend/app/projects/project_routes.py @@ -1049,6 +1049,7 @@ async def download_features(project_id: int, db: Session = Depends(database.get_ async def generate_project_tiles( background_tasks: BackgroundTasks, project_id: int, + task_id: int = None, source: str = Query( ..., description="Select a source for tiles", enum=TILES_SOURCE ), @@ -1087,6 +1088,7 @@ async def generate_project_tiles( background_task_id, source, format, + task_id, tms, ) From 6a2de7ebb95e781a713dd7cc89486d557c1d50d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:20:38 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/backend/app/projects/project_crud.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index 5706cf6b48..26c1f41ed9 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -2357,10 +2357,10 @@ def get_project_tiles( try: db.add(tile_path_instance) db.commit() - + get_id = task_id or project_id entity = "tasks" if task_id else "projects" - + # Project/task Outline log.debug(f"Getting bbox : {get_id}") query = text(