Navigation Menu

Skip to content

Commit

Permalink
[processing] homogenize input/output names in Heatmap algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jul 15, 2017
1 parent bbe466f commit 5f5fc58
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions python/plugins/processing/algs/qgis/Heatmap.py
Expand Up @@ -50,15 +50,15 @@

class Heatmap(QgisAlgorithm):

INPUT_LAYER = 'INPUT_LAYER'
INPUT = 'INPUT'
RADIUS = 'RADIUS'
RADIUS_FIELD = 'RADIUS_FIELD'
WEIGHT_FIELD = 'WEIGHT_FIELD'
PIXEL_SIZE = 'PIXEL_SIZE'
KERNEL = 'KERNEL'
DECAY = 'DECAY'
OUTPUT_VALUE = 'OUTPUT_VALUE'
OUTPUT_LAYER = 'OUTPUT_LAYER'
OUTPUT = 'OUTPUT'

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'heatmap.png'))
Expand Down Expand Up @@ -88,7 +88,7 @@ def initAlgorithm(self, config=None):
self.OUTPUT_VALUES = OrderedDict([(self.tr('Raw'), QgsKernelDensityEstimation.OutputRaw),
(self.tr('Scaled'), QgsKernelDensityEstimation.OutputScaled)])

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER,
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

Expand All @@ -100,7 +100,7 @@ def initAlgorithm(self, config=None):
radius_field_param = QgsProcessingParameterField(self.RADIUS_FIELD,
self.tr('Radius from field'),
None,
self.INPUT_LAYER,
self.INPUT,
QgsProcessingParameterField.Numeric,
optional=True
)
Expand All @@ -118,7 +118,7 @@ def __init__(self, name='', description='', parent_layer=None, radius_param=None

pixel_size_param = ParameterHeatmapPixelSize(self.PIXEL_SIZE,
self.tr('Output raster size'),
parent_layer=self.INPUT_LAYER,
parent_layer=self.INPUT,
radius_param=self.RADIUS,
radius_field_param=self.RADIUS_FIELD,
minValue=0.0,
Expand All @@ -132,7 +132,7 @@ def __init__(self, name='', description='', parent_layer=None, radius_param=None
weight_field_param = QgsProcessingParameterField(self.WEIGHT_FIELD,
self.tr('Weight from field'),
None,
self.INPUT_LAYER,
self.INPUT,
QgsProcessingParameterField.Numeric,
optional=True
)
Expand Down Expand Up @@ -164,17 +164,17 @@ def __init__(self, name='', description='', parent_layer=None, radius_param=None
output_scaling.setFlags(output_scaling.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(output_scaling)

self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT_LAYER, self.tr('Heatmap')))
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT, self.tr('Heatmap')))

def processAlgorithm(self, parameters, context, feedback):
source = self.parameterAsSource(parameters, self.INPUT_LAYER, context)
source = self.parameterAsSource(parameters, self.INPUT, context)

radius = self.parameterAsDouble(parameters, self.RADIUS, context)
kernel_shape = self.parameterAsEnum(parameters, self.KERNEL, context)
pixel_size = self.parameterAsDouble(parameters, self.PIXEL_SIZE, context)
decay = self.parameterAsDouble(parameters, self.DECAY, context)
output_values = self.parameterAsEnum(parameters, self.OUTPUT_VALUE, context)
outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT_LAYER, context)
outputFile = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
output_format = raster.formatShortNameFromFileName(outputFile)
weight_field = self.parameterAsString(parameters, self.WEIGHT_FIELD, context)
radius_field = self.parameterAsString(parameters, self.RADIUS_FIELD, context)
Expand Down Expand Up @@ -221,4 +221,4 @@ def processAlgorithm(self, parameters, context, feedback):
raise QgsProcessingException(
self.tr('Could not save destination layer'))

return {self.OUTPUT_LAYER: outputFile}
return {self.OUTPUT: outputFile}

0 comments on commit 5f5fc58

Please sign in to comment.