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

Pre-generated mbtile files for each task area in a project #1080

Closed
wants to merge 13 commits into from

Conversation

nrjadkry
Copy link
Member

@nrjadkry nrjadkry commented Jan 4, 2024

Fixes #890

  1. I have uploaded the mbtiles we create in s3 bucket in this path. /orgid/projectid/basemap.mbtiles
  2. Generated task wise mbtiles from the same file path so that it uses the cache from the tiles generated when creating the mbtiles for project. and uploaded the resulting mbtile into s3 bucket.

@spwoodcock has suggested to use pmtiles rather than mbtiles when generating the project wise mbtiles. I was wondering if these pmtiles generated works for odk collect? And if not, do we need project wise mbtiles too.

@github-actions github-actions bot added the backend Related to backend code label Jan 4, 2024
@spwoodcock spwoodcock added the enhancement New feature or request label Jan 4, 2024
@robsavoye
Copy link
Collaborator

I don't believe pmtiles will work for ODK Collect.

@spwoodcock spwoodcock changed the title Task Wise Mbtiles Pre-generated mbtile files for each task area in a project Jan 4, 2024
@spwoodcock
Copy link
Member

spwoodcock commented Jan 4, 2024

No they won't.

The idea is:

  • PMTiles for project area to efficiently load everything on the web UI (when online, using OpenLayers).
  • Pre-generated MBTile archives for each task area, used when mapping (e.g. in ODK Collect).

@nrjadkry
Copy link
Member Author

nrjadkry commented Jan 5, 2024

I have revised the output format for task-wise tiles to use MBTiles. Would it be okay to initiate this endpoint during the project generation process? The endpoint already generates tiles in the background. What do you think @spwoodcock?

The idea is to trigger this endpoint at the end of project creation process, passing pmtiles from frontend as a parameter. Then, the backend will generate pmtiles for project and mbtiles for tasks.

get_project_sync = async_to_sync(get_project)
project = get_project_sync(db, project_id)

from app.s3 import add_file_to_bucket
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try not to import inline like this, it goes against the PEP8 style guide. Always import at the top of the file 👍

@spwoodcock
Copy link
Member

Code is good, but this is a larger PR than the initial code suggests and requires modifying the backend and frontend together.

The code as it is will break the functionality of generating individual tile archives.

I will push some changes to keep the existing functionality, while also running in the background on project creation as mentioned.

@spwoodcock
Copy link
Member

spwoodcock commented Jan 8, 2024

I took a quick look at this & made some edits.

I split out into two endpoints:

  • One for generation of individual basemaps, based on the UI we already have in place.
  • One to initialise all basemaps during project creation, if the option is selected in the UI.

Could I ask for some assistance with:

  • @nrjadkry could you please test the endpoints well, especially the tiles/project_id/init one.
  • And @NSUWAL123 or @varun2948 if you could make the improve upon the Select element on the Upload Area page of project creation, it would be a huge help.
  • Then finally we need to test it works as intended once a project is submitted for creation.

@nrjadkry
Copy link
Member Author

@spwoodcock @varun2948 @NSUWAL123 where are we with making changes in the frontend for this PR.

@spwoodcock
Copy link
Member

I'll look at fixing conflicts and working on a basic frontend implementation in the coming days 👍

@spwoodcock spwoodcock marked this pull request as draft July 4, 2024 17:12
@spwoodcock
Copy link
Member

Closing for now as this is too far out of sync.

We can return to it in future and use this as inspiration.

@spwoodcock spwoodcock closed this Jul 4, 2024
@spwoodcock spwoodcock deleted the feat-mbtiles branch October 18, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code enhancement New feature or request frontend Related to frontend code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow downloading of mbtiles per task
3 participants