Skip to content

Commit

Permalink
[processing] deferred transparency/bg_color option in xyz alg
Browse files Browse the repository at this point in the history
  • Loading branch information
varmar05 authored and wonder-sk committed Jun 7, 2019
1 parent ebab737 commit 4013925
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
17 changes: 3 additions & 14 deletions python/plugins/processing/algs/qgis/TilesXYZ.py
Expand Up @@ -43,8 +43,7 @@
QgsMapSettings,
QgsCoordinateTransform,
QgsCoordinateReferenceSystem,
QgsMapRendererCustomPainterJob,
QgsProject)
QgsMapRendererCustomPainterJob)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


Expand Down Expand Up @@ -130,7 +129,6 @@ class TilesXYZAlgorithmBase(QgisAlgorithm):
ZOOM_MAX = 'ZOOM_MAX'
DPI = 'DPI'
TILE_FORMAT = 'TILE_FORMAT'
TRANSPARENT = 'TRANSPARENT'
QUALITY = 'QUALITY'

def initAlgorithm(self, config=None):
Expand All @@ -155,9 +153,6 @@ def initAlgorithm(self, config=None):
self.tr('Tile format'),
self.formats,
defaultValue=0))
self.addParameter(QgsProcessingParameterBoolean(self.TRANSPARENT,
self.tr('Use transparent background (PNG only)'),
defaultValue=True))
self.addParameter(QgsProcessingParameterNumber(self.QUALITY,
self.tr('Quality (JPG only)'),
minValue=1,
Expand All @@ -178,7 +173,6 @@ def generate(self, writer, parameters, context, feedback):
self.max_zoom = self.parameterAsInt(parameters, self.ZOOM_MAX, context)
dpi = self.parameterAsInt(parameters, self.DPI, context)
self.tile_format = self.formats[self.parameterAsEnum(parameters, self.TILE_FORMAT, context)]
transparent = self.parameterAsBool(parameters, self.TRANSPARENT, context)
quality = self.parameterAsInt(parameters, self.QUALITY, context)
try:
tile_width = self.parameterAsInt(parameters, self.TILE_WIDTH, context)
Expand All @@ -199,13 +193,8 @@ def generate(self, writer, parameters, context, feedback):
settings.setDestinationCrs(dest_crs)
settings.setLayers(self.layers)
settings.setOutputDpi(dpi)
canvas_red = QgsProject.instance().readNumEntry('Gui', '/CanvasColorRedPart', 255)[0]
canvas_green = QgsProject.instance().readNumEntry('Gui', '/CanvasColorGreenPart', 255)[0]
canvas_blue = QgsProject.instance().readNumEntry('Gui', '/CanvasColorBluePart', 255)[0]
color = QColor(canvas_red, canvas_green, canvas_blue, 255)
if self.tile_format == 'PNG' and transparent:
color.setAlpha(0)
settings.setBackgroundColor(color)
if self.tile_format == 'PNG':
settings.setBackgroundColor(QColor(Qt.transparent))

self.wgs_extent = src_to_wgs.transformBoundingBox(extent)
self.wgs_extent = [self.wgs_extent.xMinimum(), self.wgs_extent.yMinimum(), self.wgs_extent.xMaximum(),
Expand Down
Expand Up @@ -2134,7 +2134,6 @@ tests:
ZOOM_MIN: 1
ZOOM_MAX: 3
TILE_FORMAT: 0 # png
ALPHA: 0 # fully transparent
TMS_CONVENTION: false
TILE_WIDTH: 256
TILE_HEIGHT: 256
Expand Down

0 comments on commit 4013925

Please sign in to comment.