Skip to content
Merged
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
9 changes: 7 additions & 2 deletions libqfieldsync/offline_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,6 @@ def _export_basemap_as_mbtiles(
"""
Exports a basemap to mbtiles format.
This method handles several zoom levels.
This should be preferred over the legacy `_export_basemap_as_tiff` method.

Args:
extent (QgsRectangle): extent of the area of interest
Expand All @@ -623,12 +622,14 @@ def _export_basemap_as_mbtiles(
.createAlgorithmById("native:tilesxyzmbtiles")
)

basemap_export_path = self._export_filename.with_name("basemap.mbtiles")

params = {
"EXTENT": extent,
"ZOOM_MIN": self.project_configuration.base_map_tiles_min_zoom_level,
"ZOOM_MAX": self.project_configuration.base_map_tiles_max_zoom_level,
"TILE_SIZE": 256,
"OUTPUT_FILE": str(self._export_filename.with_name("basemap.mbtiles")),
"OUTPUT_FILE": str(basemap_export_path),
}

# clone current QGIS project
Expand Down Expand Up @@ -686,6 +687,10 @@ def _export_basemap_as_mbtiles(
# we use a try clause to make sure the feedback's `progressChanged` signal
# is disconnected in the finally clause.
try:
# if the basemap file already exists on target destination,
# the `native:tilesxyzmbtiles` alg will throw an error.
basemap_export_path.unlink(missing_ok=True)

results, ok = alg.run(params, context, self._feedback)

if not ok:
Expand Down
Loading