Skip to content

Commit

Permalink
[processing] use feature source in the interpolation algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 11, 2017
1 parent 874c7f5 commit 2c50fd8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 48 deletions.
15 changes: 7 additions & 8 deletions python/plugins/processing/algs/gdal/GridAverage.py
Expand Up @@ -32,7 +32,7 @@
from qgis.core import (QgsRasterFileWriter,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterField,
QgsProcessingParameterNumber,
Expand Down Expand Up @@ -63,9 +63,9 @@ def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

z_field_param = QgsProcessingParameterField(self.Z_FIELD,
self.tr('Z value from field'),
Expand Down Expand Up @@ -136,11 +136,10 @@ def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context)
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

arguments = ['-l']
arguments.append(GdalUtils.ogrLayerName(connectionString))
arguments.append(layerName)

fieldName = self.parameterAsString(parameters, self.Z_FIELD, context)
if fieldName:
Expand Down Expand Up @@ -168,7 +167,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-co')
arguments.append(options)

arguments.append(connectionString)
arguments.append(ogrLayer)
arguments.append(out)

return ['gdal_grid', GdalUtils.escapeAndJoin(arguments)]
15 changes: 7 additions & 8 deletions python/plugins/processing/algs/gdal/GridDataMetrics.py
Expand Up @@ -32,7 +32,7 @@
from qgis.core import (QgsRasterFileWriter,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterField,
QgsProcessingParameterNumber,
Expand Down Expand Up @@ -72,9 +72,9 @@ def initAlgorithm(self, config=None):
(self.tr('Average distance'), 'average_distance'),
(self.tr('Average distance between points'), 'average_distance_pts'))

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

z_field_param = QgsProcessingParameterField(self.Z_FIELD,
self.tr('Z value from field'),
Expand Down Expand Up @@ -150,11 +150,10 @@ def group(self):
return self.tr('Raster analysis')

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context)
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

arguments = ['-l']
arguments.append(GdalUtils.ogrLayerName(connectionString))
arguments.append(layerName)

fieldName = self.parameterAsString(parameters, self.Z_FIELD, context)
if fieldName:
Expand Down Expand Up @@ -182,7 +181,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-co')
arguments.append(options)

arguments.append(connectionString)
arguments.append(ogrLayer)
arguments.append(out)

return ['gdal_grid', GdalUtils.escapeAndJoin(arguments)]
15 changes: 7 additions & 8 deletions python/plugins/processing/algs/gdal/GridInverseDistance.py
Expand Up @@ -33,7 +33,7 @@
from qgis.core import (QgsRasterFileWriter,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterField,
QgsProcessingParameterNumber,
Expand Down Expand Up @@ -67,9 +67,9 @@ def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

z_field_param = QgsProcessingParameterField(self.Z_FIELD,
self.tr('Z value from field'),
Expand Down Expand Up @@ -156,11 +156,10 @@ def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context)
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

arguments = ['-l']
arguments.append(GdalUtils.ogrLayerName(connectionString))
arguments.append(layerName)

fieldName = self.parameterAsString(parameters, self.Z_FIELD, context)
if fieldName:
Expand Down Expand Up @@ -191,7 +190,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-co')
arguments.append(options)

arguments.append(connectionString)
arguments.append(ogrLayer)
arguments.append(out)

return ['gdal_grid', GdalUtils.escapeAndJoin(arguments)]
Expand Up @@ -33,7 +33,7 @@
from qgis.core import (QgsRasterFileWriter,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterField,
QgsProcessingParameterNumber,
Expand Down Expand Up @@ -65,9 +65,9 @@ def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

z_field_param = QgsProcessingParameterField(self.Z_FIELD,
self.tr('Z value from field'),
Expand Down Expand Up @@ -143,11 +143,10 @@ def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context)
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

arguments = ['-l']
arguments.append(GdalUtils.ogrLayerName(connectionString))
arguments.append(layerName)

fieldName = self.parameterAsString(parameters, self.Z_FIELD, context)
if fieldName:
Expand Down Expand Up @@ -176,7 +175,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-co')
arguments.append(options)

arguments.append(connectionString)
arguments.append(ogrLayer)
arguments.append(out)

return ['gdal_grid', GdalUtils.escapeAndJoin(arguments)]
15 changes: 7 additions & 8 deletions python/plugins/processing/algs/gdal/GridLinear.py
Expand Up @@ -33,7 +33,7 @@
from qgis.core import (QgsRasterFileWriter,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterField,
QgsProcessingParameterNumber,
Expand Down Expand Up @@ -61,9 +61,9 @@ def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

z_field_param = QgsProcessingParameterField(self.Z_FIELD,
self.tr('Z value from field'),
Expand Down Expand Up @@ -118,11 +118,10 @@ def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context)
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

arguments = ['-l']
arguments.append(GdalUtils.ogrLayerName(connectionString))
arguments.append(layerName)

fieldName = self.parameterAsString(parameters, self.Z_FIELD, context)
if fieldName:
Expand All @@ -147,7 +146,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-co')
arguments.append(options)

arguments.append(connectionString)
arguments.append(ogrLayer)
arguments.append(out)

return ['gdal_grid', GdalUtils.escapeAndJoin(arguments)]
15 changes: 7 additions & 8 deletions python/plugins/processing/algs/gdal/GridNearestNeighbor.py
Expand Up @@ -33,7 +33,7 @@
from qgis.core import (QgsRasterFileWriter,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterField,
QgsProcessingParameterNumber,
Expand Down Expand Up @@ -63,9 +63,9 @@ def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Point layer'),
[QgsProcessing.TypeVectorPoint]))

z_field_param = QgsProcessingParameterField(self.Z_FIELD,
self.tr('Z value from field'),
Expand Down Expand Up @@ -131,11 +131,10 @@ def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def getConsoleCommands(self, parameters, context, feedback):
inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context)
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
ogrLayer, layerName = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

arguments = ['-l']
arguments.append(GdalUtils.ogrLayerName(connectionString))
arguments.append(layerName)

fieldName = self.parameterAsString(parameters, self.Z_FIELD, context)
if fieldName:
Expand All @@ -162,7 +161,7 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append('-co')
arguments.append(options)

arguments.append(connectionString)
arguments.append(ogrLayer)
arguments.append(out)

return ['gdal_grid', GdalUtils.escapeAndJoin(arguments)]

0 comments on commit 2c50fd8

Please sign in to comment.