Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix single threaded use of MBTiles generator
  • Loading branch information
mash-graz authored and wonder-sk committed Dec 6, 2019
1 parent 89f1640 commit cfbe664
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/plugins/processing/algs/qgis/TilesXYZ.py
Expand Up @@ -23,6 +23,7 @@

import os
import math
import re
from uuid import uuid4

import sqlite3
Expand Down Expand Up @@ -178,6 +179,7 @@ def initAlgorithm(self, config=None):
minValue=1,
maxValue=20,
defaultValue=4))
self.thread_nr_re = re.compile('[0-9]+$') # thread number regex

def prepareAlgorithm(self, parameters, context, feedback):
project = context.project()
Expand All @@ -190,10 +192,11 @@ def renderSingleMetatile(self, metatile):
return
# Haven't found a better way to break than to make all the new threads return instantly

if "Dummy" in threading.current_thread().name: # single thread testing
if "Dummy" in threading.current_thread().name or len(self.settingsDictionary) == 1: # single thread testing
threadSpecificSettings = list(self.settingsDictionary.values())[0]
else:
threadSpecificSettings = self.settingsDictionary[threading.current_thread().name[-1]] # last number only
thread_nr = self.thread_nr_re.search(threading.current_thread().name)[0] # terminating number only
threadSpecificSettings = self.settingsDictionary[thread_nr]

size = QSize(self.tile_width * metatile.rows(), self.tile_height * metatile.columns())
extent = QgsRectangle(*metatile.extent())
Expand Down

0 comments on commit cfbe664

Please sign in to comment.