@@ -607,7 +607,6 @@ def _export_basemap_as_mbtiles(
607
607
"""
608
608
Exports a basemap to mbtiles format.
609
609
This method handles several zoom levels.
610
- This should be preferred over the legacy `_export_basemap_as_tiff` method.
611
610
612
611
Args:
613
612
extent (QgsRectangle): extent of the area of interest
@@ -623,12 +622,14 @@ def _export_basemap_as_mbtiles(
623
622
.createAlgorithmById ("native:tilesxyzmbtiles" )
624
623
)
625
624
625
+ basemap_export_path = self ._export_filename .with_name ("basemap.mbtiles" )
626
+
626
627
params = {
627
628
"EXTENT" : extent ,
628
629
"ZOOM_MIN" : self .project_configuration .base_map_tiles_min_zoom_level ,
629
630
"ZOOM_MAX" : self .project_configuration .base_map_tiles_max_zoom_level ,
630
631
"TILE_SIZE" : 256 ,
631
- "OUTPUT_FILE" : str (self . _export_filename . with_name ( "basemap.mbtiles" ) ),
632
+ "OUTPUT_FILE" : str (basemap_export_path ),
632
633
}
633
634
634
635
# clone current QGIS project
@@ -686,6 +687,10 @@ def _export_basemap_as_mbtiles(
686
687
# we use a try clause to make sure the feedback's `progressChanged` signal
687
688
# is disconnected in the finally clause.
688
689
try :
690
+ # if the basemap file already exists on target destination,
691
+ # the `native:tilesxyzmbtiles` alg will throw an error.
692
+ basemap_export_path .unlink (missing_ok = True )
693
+
689
694
results , ok = alg .run (params , context , self ._feedback )
690
695
691
696
if not ok :
0 commit comments