Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task wise mbtile generation #982

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -2357,23 +2358,26 @@ def get_project_tiles(
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}")

Expand Down
2 changes: 2 additions & 0 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand Down Expand Up @@ -1087,6 +1088,7 @@ async def generate_project_tiles(
background_task_id,
source,
format,
task_id,
tms,
)

Expand Down
Loading