Skip to content

Commit 7c9d634

Browse files
committedOct 11, 2017
[processing] rename some algorithms to avoid naming conflicts and
maintain consistency
1 parent 5b7b3a9 commit 7c9d634

File tree

7 files changed

+126
-144
lines changed

7 files changed

+126
-144
lines changed
 

‎python/plugins/processing/algs/gdal/ClipByExtent.py renamed to ‎python/plugins/processing/algs/gdal/ClipRasterByExtent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
ClipByExtent.py
5+
ClipRasterByExtent.py
66
---------------------
77
Date : September 2013
88
Copyright : (C) 2013 by Alexander Bruy
@@ -44,7 +44,7 @@
4444
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
4545

4646

47-
class ClipByExtent(GdalAlgorithm):
47+
class ClipRasterByExtent(GdalAlgorithm):
4848

4949
INPUT = 'INPUT'
5050
EXTENT = 'PROJWIN'

‎python/plugins/processing/algs/gdal/ClipByMask.py renamed to ‎python/plugins/processing/algs/gdal/ClipRasterByMask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
ClipByMask.py
5+
ClipRasterByMask.py
66
---------------------
77
Date : September 2013
88
Copyright : (C) 2013 by Alexander Bruy
@@ -45,7 +45,7 @@
4545
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
4646

4747

48-
class ClipByMask(GdalAlgorithm):
48+
class ClipRasterByMask(GdalAlgorithm):
4949

5050
INPUT = 'INPUT'
5151
MASK = 'MASK'

‎python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636
from .AssignProjection import AssignProjection
3737
from .aspect import aspect
3838
from .buildvrt import buildvrt
39-
from .ClipByExtent import ClipByExtent
40-
from .ClipByMask import ClipByMask
39+
from .ClipRasterByExtent import ClipRasterByExtent
40+
from .ClipRasterByMask import ClipRasterByMask
4141
from .ColorRelief import ColorRelief
4242
from .contour import contour
4343
from .fillnodata import fillnodata
44+
from .gdalinfo import gdalinfo
4445
from .gdal2tiles import gdal2tiles
4546
from .gdal2xyz import gdal2xyz
4647
from .gdaladdo import gdaladdo
@@ -52,7 +53,6 @@
5253
from .GridLinear import GridLinear
5354
from .GridNearestNeighbor import GridNearestNeighbor
5455
from .hillshade import hillshade
55-
from .information import information
5656
from .nearblack import nearblack
5757
from .pct2rgb import pct2rgb
5858
from .polygonize import polygonize
@@ -73,8 +73,9 @@
7373
# from .gdalcalc import gdalcalc
7474
# from .rasterize_over import rasterize_over
7575

76-
from .ogr2ogrpointsonlines import Ogr2OgrPointsOnLines
77-
from .ogr2ogrtopostgis import Ogr2OgrToPostGis
76+
from .ogrinfo import ogrinfo
77+
from .OgrToPostGis import OgrToPostGis
78+
from .PointsAlongLines import PointsAlongLines
7879

7980
# from .ogr2ogr import Ogr2Ogr
8081
# from .ogr2ogrclip import Ogr2OgrClip
@@ -85,7 +86,6 @@
8586
# from .onesidebuffer import OneSideBuffer
8687
# from .offsetcurve import OffsetCurve
8788
# from .ogr2ogrtabletopostgislist import Ogr2OgrTableToPostGisList
88-
# from .ogrinfo import OgrInfo
8989
# from .ogrsql import OgrSql
9090

9191
pluginPath = os.path.normpath(os.path.join(
@@ -139,11 +139,12 @@ def loadAlgorithms(self):
139139
AssignProjection(),
140140
aspect(),
141141
buildvrt(),
142-
ClipByExtent(),
143-
ClipByMask(),
142+
ClipRasterByExtent(),
143+
ClipRasterByMask(),
144144
ColorRelief(),
145145
contour(),
146146
fillnodata(),
147+
gdalinfo(),
147148
gdal2tiles(),
148149
gdal2xyz(),
149150
gdaladdo(),
@@ -155,7 +156,6 @@ def loadAlgorithms(self):
155156
GridLinear(),
156157
GridNearestNeighbor(),
157158
hillshade(),
158-
information(),
159159
nearblack(),
160160
pct2rgb(),
161161
polygonize(),
@@ -175,9 +175,9 @@ def loadAlgorithms(self):
175175
# gdalcalc(),
176176
# rasterize_over(),
177177
# ----- OGR tools -----
178-
Ogr2OgrPointsOnLines(),
179-
Ogr2OgrToPostGis(),
180-
# OgrInfo(),
178+
ogrinfo(),
179+
OgrToPostGis(),
180+
PointsAlongLines(),
181181
# Ogr2Ogr(),
182182
# Ogr2OgrClip(),
183183
# Ogr2OgrClipExtent(),

‎python/plugins/processing/algs/gdal/ogr2ogrtopostgis.py renamed to ‎python/plugins/processing/algs/gdal/OgrToPostGis.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
ogr2ogrtopostgis.py
5+
OgrToPostGis.py
66
---------------------
77
Date : November 2012
88
Copyright : (C) 2012 by Victor Olaya
@@ -16,7 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from builtins import str
2019

2120
__author__ = 'Victor Olaya'
2221
__date__ = 'November 2012'
@@ -40,7 +39,7 @@
4039
from processing.tools.system import isWindows
4140

4241

43-
class Ogr2OgrToPostGis(GdalAlgorithm):
42+
class OgrToPostGis(GdalAlgorithm):
4443

4544
INPUT = 'INPUT'
4645
SHAPE_ENCODING = 'SHAPE_ENCODING'
@@ -309,4 +308,4 @@ def getConsoleCommands(self, parameters, context, feedback):
309308
return commands
310309

311310
def commandName(self):
312-
return "ogr2ogr"
311+
return 'ogr2ogr'

‎python/plugins/processing/algs/gdal/ogr2ogrpointsonlines.py renamed to ‎python/plugins/processing/algs/gdal/PointsAlongLines.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
ogr2ogrpointsonlines.py
5+
PointsAlongLines.py
66
---------------------
77
Date : Janaury 2015
88
Copyright : (C) 2015 by Giovanni Manghi
@@ -16,7 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from builtins import str
2019

2120
__author__ = 'Giovanni Manghi'
2221
__date__ = 'January 2015'
@@ -39,7 +38,7 @@
3938
from processing.tools.system import isWindows
4039

4140

42-
class Ogr2OgrPointsOnLines(GdalAlgorithm):
41+
class PointsAlongLines(GdalAlgorithm):
4342

4443
OUTPUT = 'OUTPUT'
4544
INPUT = 'INPUT'
@@ -65,7 +64,7 @@ def initAlgorithm(self, config=None):
6564
self.addParameter(QgsProcessingParameterVectorDestination(self.OUTPUT, self.tr('Points along lines'), QgsProcessing.TypeVectorPoint))
6665

6766
def name(self):
68-
return 'createpointsalonglines'
67+
return 'pointsalonglines'
6968

7069
def displayName(self):
7170
return self.tr('Create points along lines')
@@ -124,4 +123,4 @@ def getConsoleCommands(self, parameters, context, feedback):
124123
return commands
125124

126125
def commandName(self):
127-
return "ogr2ogr"
126+
return 'ogr2ogr'

‎python/plugins/processing/algs/gdal/information.py renamed to ‎python/plugins/processing/algs/gdal/gdalinfo.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
***************************************************************************
5-
information.py
5+
gdalinfo.py
66
---------------------
77
Date : August 2012
88
Copyright : (C) 2012 by Victor Olaya
@@ -33,40 +33,36 @@
3333
QgsProcessingParameterFileDestination,
3434
QgsProcessingOutputHtml)
3535
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
36-
from processing.core.outputs import OutputHTML
3736
from processing.algs.gdal.GdalUtils import GdalUtils
3837

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

4140

42-
class information(GdalAlgorithm):
41+
class gdalinfo(GdalAlgorithm):
4342

4443
INPUT = 'INPUT'
4544
MIN_MAX = 'MIN_MAX'
4645
STATS = 'STATS'
47-
NOGCP = 'NOGCP'
48-
NOMETADATA = 'NOMETADATA'
46+
NO_GCP = 'NOGCP'
47+
NO_METADATA = 'NO_METADATA'
4948
OUTPUT = 'OUTPUT'
5049

51-
def icon(self):
52-
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))
53-
5450
def __init__(self):
5551
super().__init__()
5652

5753
def initAlgorithm(self, config=None):
58-
self.addParameter(QgsProcessingParameterRasterLayer(information.INPUT,
54+
self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT,
5955
self.tr('Input layer')))
60-
self.addParameter(QgsProcessingParameterBoolean(information.MIN_MAX,
56+
self.addParameter(QgsProcessingParameterBoolean(self.MIN_MAX,
6157
self.tr('Force computation of the actual min/max values for each band'),
6258
defaultValue=False))
63-
self.addParameter(QgsProcessingParameterBoolean(information.STATS,
59+
self.addParameter(QgsProcessingParameterBoolean(self.STATS,
6460
self.tr('Read and display image statistics (force computation if necessary)'),
6561
defaultValue=False))
66-
self.addParameter(QgsProcessingParameterBoolean(information.NOGCP,
62+
self.addParameter(QgsProcessingParameterBoolean(self.NO_GCP,
6763
self.tr('Suppress GCP info'),
6864
defaultValue=False))
69-
self.addParameter(QgsProcessingParameterBoolean(information.NOMETADATA,
65+
self.addParameter(QgsProcessingParameterBoolean(self.NO_METADATA,
7066
self.tr('Suppress metadata info'),
7167
defaultValue=False))
7268

@@ -79,22 +75,25 @@ def name(self):
7975
return 'gdalinfo'
8076

8177
def displayName(self):
82-
return self.tr('Information')
78+
return self.tr('Raster information')
8379

8480
def group(self):
8581
return self.tr('Raster miscellaneous')
8682

83+
def icon(self):
84+
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))
85+
8786
def getConsoleCommands(self, parameters, context, feedback):
8887
arguments = []
89-
if self.parameterAsBool(parameters, information.MIN_MAX, context):
88+
if self.parameterAsBool(parameters, self.MIN_MAX, context):
9089
arguments.append('-mm')
91-
if self.parameterAsBool(parameters, information.STATS, context):
90+
if self.parameterAsBool(parameters, self.STATS, context):
9291
arguments.append('-stats')
93-
if self.parameterAsBool(parameters, information.NOGCP, context):
92+
if self.parameterAsBool(parameters, self.NO_GCP, context):
9493
arguments.append('-nogcp')
95-
if self.parameterAsBool(parameters, information.NOMETADATA, context):
94+
if self.parameterAsBool(parameters, self.NO_METADATA, context):
9695
arguments.append('-nomd')
97-
arguments.append(self.parameterAsRasterLayer(parameters, information.INPUT, context).source())
96+
arguments.append(self.parameterAsRasterLayer(parameters, self.INPUT, context).source())
9897
return ['gdalinfo', GdalUtils.escapeAndJoin(arguments)]
9998

10099
def processAlgorithm(self, parameters, context, feedback):

‎python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml

Lines changed: 85 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests:
2+
23
- algorithm: gdal:gdalinfo
34
name: gdalinfo
45
params:
@@ -273,7 +274,39 @@ tests:
273274
hash: a497763f44380ec33acab572a926a6516e875f2284fc55e702abbdfc
274275
type: rasterhash
275276

276-
# - algorithm: gdal:ogrinfo
277+
# - algorithm: gdal:merge
278+
# name: Merge 2 raster layers
279+
# params:
280+
# INPUT:
281+
# params:
282+
# - name: custom/dem_to_merge1.tif
283+
# type: raster
284+
# - name: custom/dem_to_merge2.tif
285+
# type: raster
286+
# type: multi
287+
# PCT: false
288+
# RTYPE: '5'
289+
# SEPARATE: false
290+
# results:
291+
# OUTPUT:
292+
# hash: fb6f0f4081308cc188eda2fbe106e04e0ebf866fc56853f0cca8db1c
293+
# type: rasterhash
294+
#
295+
# - algorithm: gdal:rastercalculator
296+
# name: Simple Raster Calculator test with only 1 raster
297+
# params:
298+
# BAND_A: '1'
299+
# FORMULA: A/2
300+
# INPUT_A:
301+
# name: dem.tif
302+
# type: raster
303+
# RTYPE: '5'
304+
# results:
305+
# OUTPUT:
306+
# hash: 2d0585dc8166fbe3cec7d9e6fd66e95cc9bdb1043b3b0fa7cbdfef4c
307+
# type: rasterhash
308+
309+
# - algorithm: gdal:ogrinfo
277310
# name: ogrinfo
278311
# params:
279312
# INPUT:
@@ -288,64 +321,8 @@ tests:
288321
# - 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
289322
# - 'Geometry: Line String'
290323
# - 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7...
291-
#
292-
# - algorithm: gdal:buffervectors
293-
# name: Buffer lines
294-
# params:
295-
# DISSOLVEALL: false
296-
# DISTANCE: 1.0
297-
# GEOMETRY: geometry
298-
# INPUT_LAYER:
299-
# name: lines.gml
300-
# type: vector
301-
# MULTI: false
302-
# results:
303-
# OUTPUT_LAYER:
304-
# name: expected/gdal/buffer_lines.gml
305-
# type: vector
306-
# compare:
307-
# geometry:
308-
# precision: 7
309-
# expectedFailure:
310-
# - int(1)
311-
#
312-
# - algorithm: gdal:buffervectors
313-
# name: Basic polygon buffer
314-
# params:
315-
# DISSOLVEALL: false
316-
# DISTANCE: 0.5
317-
# GEOMETRY: geometry
318-
# INPUT_LAYER:
319-
# name: polys.gml
320-
# type: vector
321-
# MULTI: false
322-
# results:
323-
# OUTPUT_LAYER:
324-
# name: expected/gdal/buffer_polys.gml
325-
# type: vector
326-
# compare:
327-
# geometry:
328-
# precision: 7
329-
#
330-
# - algorithm: gdal:buffervectors
331-
# name: Polygon buffer with dissolve
332-
# params:
333-
# DISSOLVEALL: true
334-
# DISTANCE: 0.5
335-
# GEOMETRY: geometry
336-
# INPUT_LAYER:
337-
# name: polys.gml
338-
# type: vector
339-
# MULTI: false
340-
# results:
341-
# OUTPUT_LAYER:
342-
# name: expected/gdal/buffer_polys_dissolve.gml
343-
# type: vector
344-
# compare:
345-
# geometry:
346-
# precision: 7
347-
#
348-
- algorithm: gdal:createpointsalonglines
324+
325+
- algorithm: gdal:pointsalonglines
349326
name: Points along lines
350327
params:
351328
DISTANCE: 0.25
@@ -396,52 +373,60 @@ tests:
396373
# geometry:
397374
# precision: 7
398375
#
399-
# - algorithm: gdal:merge
400-
# name: Merge 2 raster layers
376+
# - algorithm: gdal:buffervectors
377+
# name: Buffer lines
401378
# params:
402-
# INPUT:
403-
# params:
404-
# - name: custom/dem_to_merge1.tif
405-
# type: raster
406-
# - name: custom/dem_to_merge2.tif
407-
# type: raster
408-
# type: multi
409-
# PCT: false
410-
# RTYPE: '5'
411-
# SEPARATE: false
379+
# DISSOLVEALL: false
380+
# DISTANCE: 1.0
381+
# GEOMETRY: geometry
382+
# INPUT_LAYER:
383+
# name: lines.gml
384+
# type: vector
385+
# MULTI: false
412386
# results:
413-
# OUTPUT:
414-
# hash: fb6f0f4081308cc188eda2fbe106e04e0ebf866fc56853f0cca8db1c
415-
# type: rasterhash
387+
# OUTPUT_LAYER:
388+
# name: expected/gdal/buffer_lines.gml
389+
# type: vector
390+
# compare:
391+
# geometry:
392+
# precision: 7
393+
# expectedFailure:
394+
# - int(1)
416395
#
417-
# - algorithm: gdal:merge
418-
# name: Merge layers and separate in bands
396+
# - algorithm: gdal:buffervectors
397+
# name: Basic polygon buffer
419398
# params:
420-
# INPUT:
421-
# params:
422-
# - name: custom/dem_to_merge1.tif
423-
# type: raster
424-
# - name: custom/dem_to_merge2.tif
425-
# type: raster
426-
# type: multi
427-
# PCT: false
428-
# RTYPE: '5'
429-
# SEPARATE: true
399+
# DISSOLVEALL: false
400+
# DISTANCE: 0.5
401+
# GEOMETRY: geometry
402+
# INPUT_LAYER:
403+
# name: polys.gml
404+
# type: vector
405+
# MULTI: false
430406
# results:
431-
# OUTPUT:
432-
# hash: cbf7b8ca91e7d6cab5ef76eeed6ce80e5dbe173afb7b8eb4aed2e969
433-
# type: rasterhash
407+
# OUTPUT_LAYER:
408+
# name: expected/gdal/buffer_polys.gml
409+
# type: vector
410+
# compare:
411+
# geometry:
412+
# precision: 7
434413
#
435-
# - algorithm: gdal:rastercalculator
436-
# name: Simple Raster Calculator test with only 1 raster
414+
# - algorithm: gdal:buffervectors
415+
# name: Polygon buffer with dissolve
437416
# params:
438-
# BAND_A: '1'
439-
# FORMULA: A/2
440-
# INPUT_A:
441-
# name: dem.tif
442-
# type: raster
443-
# RTYPE: '5'
417+
# DISSOLVEALL: true
418+
# DISTANCE: 0.5
419+
# GEOMETRY: geometry
420+
# INPUT_LAYER:
421+
# name: polys.gml
422+
# type: vector
423+
# MULTI: false
444424
# results:
445-
# OUTPUT:
446-
# hash: 2d0585dc8166fbe3cec7d9e6fd66e95cc9bdb1043b3b0fa7cbdfef4c
447-
# type: rasterhash
425+
# OUTPUT_LAYER:
426+
# name: expected/gdal/buffer_polys_dissolve.gml
427+
# type: vector
428+
# compare:
429+
# geometry:
430+
# precision: 7
431+
#
432+

0 commit comments

Comments
 (0)
Please sign in to comment.