Skip to content
Permalink
Browse files

Merge pull request #3891 from alexbruy/processing-interpolation

[processing] add remaining functionalify from the interpolation plugin
  • Loading branch information
alexbruy committed Dec 22, 2016
2 parents 835abb9 + ea4f05d commit ffd67f119e01e8460414d3f0a94931c87e407092
Showing with 499 additions and 2,255 deletions.
  1. +0 −1 debian/qgis.install
  2. +0 −1 ms-windows/osgeo4w/package.cmd
  3. +0 −1 ms-windows/plugins.nsh
  4. +82 −40 python/plugins/processing/algs/qgis/{IdwInterpolationZValue.py → IdwInterpolation.py}
  5. +0 −147 python/plugins/processing/algs/qgis/IdwInterpolationAttribute.py
  6. +3 −6 python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
  7. +86 −40 python/plugins/processing/algs/qgis/{TinInterpolationZValue.py → TinInterpolation.py}
  8. +0 −163 python/plugins/processing/algs/qgis/TinInterpolationAttribute.py
  9. +174 −0 python/plugins/processing/algs/qgis/ui/InterpolationDataWidget.py
  10. +130 −0 python/plugins/processing/algs/qgis/ui/interpolationdatawidgetbase.ui
  11. +8 −0 python/plugins/processing/tests/AlgorithmsTestBase.py
  12. +16 −22 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  13. +0 −1 src/plugins/CMakeLists.txt
  14. +0 −70 src/plugins/interpolation/CMakeLists.txt
  15. +0 −5 src/plugins/interpolation/interpolator.qrc
  16. +0 −33 src/plugins/interpolation/qgsidwinterpolatordialog.cpp
  17. +0 −38 src/plugins/interpolation/qgsidwinterpolatordialog.h
  18. +0 −94 src/plugins/interpolation/qgsidwinterpolatordialogbase.ui
  19. +0 −589 src/plugins/interpolation/qgsinterpolationdialog.cpp
  20. +0 −83 src/plugins/interpolation/qgsinterpolationdialog.h
  21. +0 −408 src/plugins/interpolation/qgsinterpolationdialogbase.ui
  22. +0 −104 src/plugins/interpolation/qgsinterpolationplugin.cpp
  23. +0 −49 src/plugins/interpolation/qgsinterpolationplugin.h
  24. +0 −33 src/plugins/interpolation/qgsinterpolatordialog.cpp
  25. +0 −51 src/plugins/interpolation/qgsinterpolatordialog.h
  26. +0 −99 src/plugins/interpolation/qgstininterpolatordialog.cpp
  27. +0 −41 src/plugins/interpolation/qgstininterpolatordialog.h
  28. +0 −136 src/plugins/interpolation/qgstininterpolatordialogbase.ui
  29. BIN src/plugins/interpolation/raster-interpolate.png
@@ -1,6 +1,5 @@
usr/lib/qgis/plugins/libgeorefplugin.so
usr/lib/qgis/plugins/libgpsimporterplugin.so
usr/lib/qgis/plugins/libinterpolationplugin.so
usr/lib/qgis/plugins/libcoordinatecaptureplugin.so
usr/lib/qgis/plugins/liboracleplugin.so
usr/lib/qgis/plugins/libevis.so
@@ -385,7 +385,6 @@ tar -C %OSGEO4W_ROOT% -cjf %ARCH%/release/qgis/%PACKAGENAME%/%PACKAGENAME%-%VERS
"apps/%PACKAGENAME%/plugins/evis.dll" ^
"apps/%PACKAGENAME%/plugins/georefplugin.dll" ^
"apps/%PACKAGENAME%/plugins/gpsimporterplugin.dll" ^
"apps/%PACKAGENAME%/plugins/interpolationplugin.dll" ^
"apps/%PACKAGENAME%/plugins/offlineeditingplugin.dll" ^
"apps/%PACKAGENAME%/plugins/oracleplugin.dll" ^
"apps/%PACKAGENAME%/plugins/spatialqueryplugin.dll" ^
@@ -14,7 +14,6 @@ WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "georefplugin" "true
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "globeplugin" "false"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "gpsimporterplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "grassplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "interpolationplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "offlineeditingplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "oracleplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "spatialqueryplugin" "true"
@@ -2,7 +2,7 @@

"""
***************************************************************************
IdwInterpolationZValue.py
IdwInterpolation.py
---------------------
Date : October 2016
Copyright : (C) 2016 by Alexander Bruy
@@ -29,28 +29,28 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsRectangle, QgsWkbTypes
from qgis.core import QgsRectangle
from qgis.analysis import (QgsInterpolator,
QgsIDWInterpolator,
QgsGridFileWriter
)
)

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterSelection
from processing.core.parameters import ParameterNumber
from processing.core.parameters import ParameterExtent
from processing.core.parameters import (Parameter,
ParameterNumber,
ParameterExtent,
_splitParameterOptions
)
from processing.core.outputs import OutputRaster
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]


class IdwInterpolationZValue(GeoAlgorithm):
class IdwInterpolation(GeoAlgorithm):

INPUT_LAYER = 'INPUT_LAYER'
LAYER_TYPE = 'LAYER_TYPE'
INTERPOLATION_DATA = 'INTERPOLATION_DATA'
DISTANCE_COEFFICIENT = 'DISTANCE_COEFFICIENT'
COLUMNS = 'COLUMNS'
ROWS = 'ROWS'
@@ -63,20 +63,61 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'interpolation.png'))

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('IDW interpolation (using Z-values)')
self.name, self.i18n_name = self.trAlgorithm('IDW interpolation')
self.group, self.i18n_group = self.trAlgorithm('Interpolation')

self.TYPES = [self.tr('Points'),
self.tr('Structure lines'),
self.tr('Break lines')
]

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Vector layer')))
self.addParameter(ParameterSelection(self.LAYER_TYPE,
self.tr('Type'),
self.TYPES,
0))
class ParameterInterpolationData(Parameter):
default_metadata = {
'widget_wrapper': 'processing.algs.qgis.ui.InterpolationDataWidget.InterpolationDataWidgetWrapper'
}

def __init__(self, name='', description=''):
Parameter.__init__(self, name, description)

def setValue(self, value):
if value is None:
if not self.optional:
return False
self.value = None
return True

if value == '':
if not self.optional:
return False

if isinstance(value, str):
self.value = value if value != '' else None
else:
self.value = ParameterInterpolationData.dataToString(value)
return True

def getValueAsCommandLineParameter(self):
return '"{}"'.format(self.value)

def getAsScriptCode(self):
param_type = ''
param_type += 'interpolation data '
return '##' + self.name + '=' + param_type

@classmethod
def fromScriptCode(self, line):
isOptional, name, definition = _splitParameterOptions(line)
descName = _createDescriptiveName(name)
parent = definition.lower().strip()[len('interpolation data') + 1:]
return ParameterInterpolationData(name, description, parent)

@staticmethod
def dataToString(data):
s = ''
for d in data:
s += '{}, {}, {:d}, {:d};'.format(c[0],
c[1],
c[2],
c[3])
return s[:-1]

self.addParameter(ParameterInterpolationData(self.INTERPOLATION_DATA,
self.tr('Input layer(s)')))
self.addParameter(ParameterNumber(self.DISTANCE_COEFFICIENT,
self.tr('Distance coefficient P'),
0.0, 99.99, 2.0))
@@ -98,9 +139,7 @@ def defineCharacteristics(self):
self.tr('Interpolated')))

def processAlgorithm(self, progress):
layer = dataobjects.getObjectFromUri(
self.getParameterValue(self.INPUT_LAYER))
layerType = self.getParameterValue(self.LAYER_TYPE)
interpolationData = self.getParameterValue(self.INTERPOLATION_DATA)
coefficient = self.getParameterValue(self.DISTANCE_COEFFICIENT)
columns = self.getParameterValue(self.COLUMNS)
rows = self.getParameterValue(self.ROWS)
@@ -109,29 +148,32 @@ def processAlgorithm(self, progress):
extent = self.getParameterValue(self.EXTENT).split(',')
output = self.getOutputValue(self.OUTPUT_LAYER)

if not QgsWkbTypes.hasZ(layer.wkbType()):
if interpolationData is None:
raise GeoAlgorithmExecutionException(
self.tr('Geometries in input layer does not have Z coordinates.'))
self.tr('You need to specify at least one input layer.'))

xMin = float(extent[0])
xMax = float(extent[1])
yMin = float(extent[2])
yMax = float(extent[3])
bbox = QgsRectangle(xMin, yMin, xMax, yMax)

layerData = QgsInterpolator.LayerData()
layerData.vectorLayer = layer
layerData.zCoordInterpolation = True
layerData.interpolationAttribute = -1

if layerType == 0:
layerData.mInputType = QgsInterpolator.POINTS
elif layerType == 1:
layerData.mInputType = QgsInterpolator.STRUCTURE_LINES
else:
layerData.mInputType = QgsInterpolator.BREAK_LINES

interpolator = QgsIDWInterpolator([layerData])
layerData = []
for row in interpolationData.split(';'):
v = row.split(',')
data = QgsInterpolator.LayerData()
data.vectorLayer = dataobjects.getObjectFromUri(v[0])
data.zCoordInterpolation = bool(v[1])
data.interpolationAttribute = int(v[2])
if v[3] == '0':
data.mInputType = QgsInterpolator.POINTS
elif v[3] == '1':
data.mInputType = QgsInterpolator.STRUCTURE_LINES
else:
data.mInputType = QgsInterpolator.BREAK_LINES
layerData.append(data)

interpolator = QgsIDWInterpolator(layerData)
interpolator.setDistanceCoefficient(coefficient)

writer = QgsGridFileWriter(interpolator,

This file was deleted.

@@ -167,10 +167,8 @@
from .Ruggedness import Ruggedness
from .Hillshade import Hillshade
from .Relief import Relief
from .IdwInterpolationZValue import IdwInterpolationZValue
from .IdwInterpolationAttribute import IdwInterpolationAttribute
from .TinInterpolationZValue import TinInterpolationZValue
from .TinInterpolationAttribute import TinInterpolationAttribute
from .IdwInterpolation import IdwInterpolation
from .TinInterpolation import TinInterpolation
from .ZonalStatisticsQgis import ZonalStatisticsQgis
from .RemoveNullGeometry import RemoveNullGeometry
from .ExtendLines import ExtendLines
@@ -248,8 +246,7 @@ def __init__(self):
SingleSidedBuffer(), PointsAlongGeometry(),
Aspect(), Slope(), Ruggedness(), Hillshade(),
Relief(), ZonalStatisticsQgis(),
IdwInterpolationZValue(), IdwInterpolationAttribute(),
TinInterpolationZValue(), TinInterpolationAttribute(),
IdwInterpolation(), TinInterpolation(),
RemoveNullGeometry(), ExtractByExpression(),
ExtendLines(), ExtractSpecificNodes(),
GeometryByExpression(), SnapGeometriesToLayer(),

0 comments on commit ffd67f1

Please sign in to comment.
You can’t perform that action at this time.