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

Export basemap as mbtiles during cable export #105

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gounux
Copy link
Member

@gounux gounux commented Feb 20, 2025

This PR makes the cable export generate a mbtiles basemap for QField, thus enabling multiple raster zoom levels.

Subtasks:

  • add generated mbtiles min and max zoom in project configuration
  • use QGIS' native:tilesxyzmbtiles processing algorithm to generate a mbtiles file
  • implement Single layer basemap mbtiles export during cable export
  • test Single layer basemap mbtiles export during cable export
  • test Single layer basemap mbtiles in QField app
  • implement Map theme basemap mbtiles export during cable export
  • test Map theme basemap mbtiles export during cable export as well as QField usage
  • test Map theme basemap mbtiles in QField app

Copy link
Member Author

@gounux gounux left a comment

Choose a reason for hiding this comment

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

Thoughts and reflections about the ongoing dev work made so far.

ping @suricactus

@@ -556,6 +558,26 @@ def _export_basemap(self) -> bool:
)
return False

exported_tiff = self._export_basemap_as_tiff(extent, base_map_type)
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this tiff basemap generation function still be called there ?

feedback = QgsProcessingFeedback()
context = QgsProcessingContext()
context.setProject(project)
context.setFlags(context.flags() | QgsProcessingAlgorithm.FlagNoThreading)
Copy link
Member Author

Choose a reason for hiding this comment

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

Have been adding this line to stabilize the behaviour of the export, since I faced some QGIS crashes when developing this.

Con side: makes the external processing alg run on the main thread, thus freezing QGIS during this mbtiles export, which might possibly be long in case the user has some data on a large area, and configured min/max tiles zoom level with a big interval.

This needs to be discussed IMO.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For sure we should not be running this on the main thread. Let's discuss ways to run this in the background.

@property
def base_map_tiles_min_zoom_level(self) -> int:
base_map_tiles_min_zoom_level, _ = self.project.readNumEntry(
"qfieldsync", ProjectProperties.BASE_MAP_TILES_MIN_ZOOM_LEVEL, 14
Copy link
Member Author

Choose a reason for hiding this comment

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

Am wondering about mbtiles min / max zoom default values. My proposition is 14 / 16, open to discussion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would better go for 14/14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants