Skip to content

Commit

Permalink
Update Rasterize.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Trashmonk authored and m-kuhn committed Dec 21, 2017
1 parent 82df4de commit d908518
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions python/plugins/processing/algs/qgis/Rasterize.py
Expand Up @@ -110,7 +110,7 @@ def initAlgorithm(self, config=None):
self.MAKE_BACKGROUND_TRANSPARENT,
self.tr('Make background transparent'),
defaultValue=False))

map_theme_param = QgsProcessingParameterString(
self.MAP_THEME,
description=self.tr(
Expand All @@ -136,7 +136,6 @@ def initAlgorithm(self, config=None):
self.tr(
'Output layer')))


def name(self):
# Unique (non-user visible) name of algorithm
return 'rasterize'
Expand Down Expand Up @@ -184,7 +183,7 @@ def processAlgorithm(self, parameters, context, feedback):
parameters,
self.MAKE_BACKGROUND_TRANSPARENT,
context)

mupp = self.parameterAsDouble(
parameters,
self.MAP_UNITS_PER_PIXEL,
Expand Down Expand Up @@ -244,12 +243,12 @@ def __init__(self, map_theme, layer, extent, tile_size, mupp, output,
no_bands = 4
else:
no_bands = 3

self.dataset = driver.Create(output, xsize, ysize, no_bands)
self.dataset.SetProjection(str(crs.toWkt()))
self.dataset.SetGeoTransform(
[extent.xMinimum(), mupp, 0, extent.yMaximum(), 0, -mupp])

self.image = QImage(QSize(tile_size, tile_size), QImage.Format_ARGB32)

self.settings = QgsMapSettings()
Expand All @@ -265,7 +264,7 @@ def __init__(self, map_theme, layer, extent, tile_size, mupp, output,
self.settings.setBackgroundColor(QColor(255, 255, 255, 0))
else:
self.settings.setBackgroundColor(QColor(255, 255, 255))

if QgsProject.instance().mapThemeCollection().hasMapTheme(map_theme):
self.settings.setLayers(
QgsProject.instance().mapThemeCollection(
Expand Down Expand Up @@ -318,7 +317,7 @@ def renderTile(self, x, y, feedback, make_trans):
job = QgsMapRendererCustomPainterJob(self.settings, painter)
job.renderSynchronously()
painter.end()

# Needs not to be deleted or Windows will kill it too early...
tmpfile = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
try:
Expand Down

0 comments on commit d908518

Please sign in to comment.