Skip to content

Commit

Permalink
[processing] rename some algorithms to avoid naming conflicts and
Browse files Browse the repository at this point in the history
maintain consistency
  • Loading branch information
alexbruy committed Oct 11, 2017
1 parent 5b7b3a9 commit 7c9d634
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
***************************************************************************
ClipByExtent.py
ClipRasterByExtent.py
---------------------
Date : September 2013
Copyright : (C) 2013 by Alexander Bruy
Expand Down Expand Up @@ -44,7 +44,7 @@
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]


class ClipByExtent(GdalAlgorithm):
class ClipRasterByExtent(GdalAlgorithm):

INPUT = 'INPUT'
EXTENT = 'PROJWIN'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
***************************************************************************
ClipByMask.py
ClipRasterByMask.py
---------------------
Date : September 2013
Copyright : (C) 2013 by Alexander Bruy
Expand Down Expand Up @@ -45,7 +45,7 @@
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]


class ClipByMask(GdalAlgorithm):
class ClipRasterByMask(GdalAlgorithm):

INPUT = 'INPUT'
MASK = 'MASK'
Expand Down
24 changes: 12 additions & 12 deletions python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
from .AssignProjection import AssignProjection
from .aspect import aspect
from .buildvrt import buildvrt
from .ClipByExtent import ClipByExtent
from .ClipByMask import ClipByMask
from .ClipRasterByExtent import ClipRasterByExtent
from .ClipRasterByMask import ClipRasterByMask
from .ColorRelief import ColorRelief
from .contour import contour
from .fillnodata import fillnodata
from .gdalinfo import gdalinfo
from .gdal2tiles import gdal2tiles
from .gdal2xyz import gdal2xyz
from .gdaladdo import gdaladdo
Expand All @@ -52,7 +53,6 @@
from .GridLinear import GridLinear
from .GridNearestNeighbor import GridNearestNeighbor
from .hillshade import hillshade
from .information import information
from .nearblack import nearblack
from .pct2rgb import pct2rgb
from .polygonize import polygonize
Expand All @@ -73,8 +73,9 @@
# from .gdalcalc import gdalcalc
# from .rasterize_over import rasterize_over

from .ogr2ogrpointsonlines import Ogr2OgrPointsOnLines
from .ogr2ogrtopostgis import Ogr2OgrToPostGis
from .ogrinfo import ogrinfo
from .OgrToPostGis import OgrToPostGis
from .PointsAlongLines import PointsAlongLines

# from .ogr2ogr import Ogr2Ogr
# from .ogr2ogrclip import Ogr2OgrClip
Expand All @@ -85,7 +86,6 @@
# from .onesidebuffer import OneSideBuffer
# from .offsetcurve import OffsetCurve
# from .ogr2ogrtabletopostgislist import Ogr2OgrTableToPostGisList
# from .ogrinfo import OgrInfo
# from .ogrsql import OgrSql

pluginPath = os.path.normpath(os.path.join(
Expand Down Expand Up @@ -139,11 +139,12 @@ def loadAlgorithms(self):
AssignProjection(),
aspect(),
buildvrt(),
ClipByExtent(),
ClipByMask(),
ClipRasterByExtent(),
ClipRasterByMask(),
ColorRelief(),
contour(),
fillnodata(),
gdalinfo(),
gdal2tiles(),
gdal2xyz(),
gdaladdo(),
Expand All @@ -155,7 +156,6 @@ def loadAlgorithms(self):
GridLinear(),
GridNearestNeighbor(),
hillshade(),
information(),
nearblack(),
pct2rgb(),
polygonize(),
Expand All @@ -175,9 +175,9 @@ def loadAlgorithms(self):
# gdalcalc(),
# rasterize_over(),
# ----- OGR tools -----
Ogr2OgrPointsOnLines(),
Ogr2OgrToPostGis(),
# OgrInfo(),
ogrinfo(),
OgrToPostGis(),
PointsAlongLines(),
# Ogr2Ogr(),
# Ogr2OgrClip(),
# Ogr2OgrClipExtent(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
***************************************************************************
ogr2ogrtopostgis.py
OgrToPostGis.py
---------------------
Date : November 2012
Copyright : (C) 2012 by Victor Olaya
Expand All @@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from builtins import str

__author__ = 'Victor Olaya'
__date__ = 'November 2012'
Expand All @@ -40,7 +39,7 @@
from processing.tools.system import isWindows


class Ogr2OgrToPostGis(GdalAlgorithm):
class OgrToPostGis(GdalAlgorithm):

INPUT = 'INPUT'
SHAPE_ENCODING = 'SHAPE_ENCODING'
Expand Down Expand Up @@ -309,4 +308,4 @@ def getConsoleCommands(self, parameters, context, feedback):
return commands

def commandName(self):
return "ogr2ogr"
return 'ogr2ogr'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
***************************************************************************
ogr2ogrpointsonlines.py
PointsAlongLines.py
---------------------
Date : Janaury 2015
Copyright : (C) 2015 by Giovanni Manghi
Expand All @@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from builtins import str

__author__ = 'Giovanni Manghi'
__date__ = 'January 2015'
Expand All @@ -39,7 +38,7 @@
from processing.tools.system import isWindows


class Ogr2OgrPointsOnLines(GdalAlgorithm):
class PointsAlongLines(GdalAlgorithm):

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

def name(self):
return 'createpointsalonglines'
return 'pointsalonglines'

def displayName(self):
return self.tr('Create points along lines')
Expand Down Expand Up @@ -124,4 +123,4 @@ def getConsoleCommands(self, parameters, context, feedback):
return commands

def commandName(self):
return "ogr2ogr"
return 'ogr2ogr'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
***************************************************************************
information.py
gdalinfo.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Expand Down Expand Up @@ -33,40 +33,36 @@
QgsProcessingParameterFileDestination,
QgsProcessingOutputHtml)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.core.outputs import OutputHTML
from processing.algs.gdal.GdalUtils import GdalUtils

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


class information(GdalAlgorithm):
class gdalinfo(GdalAlgorithm):

INPUT = 'INPUT'
MIN_MAX = 'MIN_MAX'
STATS = 'STATS'
NOGCP = 'NOGCP'
NOMETADATA = 'NOMETADATA'
NO_GCP = 'NOGCP'
NO_METADATA = 'NO_METADATA'
OUTPUT = 'OUTPUT'

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterRasterLayer(information.INPUT,
self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT,
self.tr('Input layer')))
self.addParameter(QgsProcessingParameterBoolean(information.MIN_MAX,
self.addParameter(QgsProcessingParameterBoolean(self.MIN_MAX,
self.tr('Force computation of the actual min/max values for each band'),
defaultValue=False))
self.addParameter(QgsProcessingParameterBoolean(information.STATS,
self.addParameter(QgsProcessingParameterBoolean(self.STATS,
self.tr('Read and display image statistics (force computation if necessary)'),
defaultValue=False))
self.addParameter(QgsProcessingParameterBoolean(information.NOGCP,
self.addParameter(QgsProcessingParameterBoolean(self.NO_GCP,
self.tr('Suppress GCP info'),
defaultValue=False))
self.addParameter(QgsProcessingParameterBoolean(information.NOMETADATA,
self.addParameter(QgsProcessingParameterBoolean(self.NO_METADATA,
self.tr('Suppress metadata info'),
defaultValue=False))

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

def displayName(self):
return self.tr('Information')
return self.tr('Raster information')

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

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))

def getConsoleCommands(self, parameters, context, feedback):
arguments = []
if self.parameterAsBool(parameters, information.MIN_MAX, context):
if self.parameterAsBool(parameters, self.MIN_MAX, context):
arguments.append('-mm')
if self.parameterAsBool(parameters, information.STATS, context):
if self.parameterAsBool(parameters, self.STATS, context):
arguments.append('-stats')
if self.parameterAsBool(parameters, information.NOGCP, context):
if self.parameterAsBool(parameters, self.NO_GCP, context):
arguments.append('-nogcp')
if self.parameterAsBool(parameters, information.NOMETADATA, context):
if self.parameterAsBool(parameters, self.NO_METADATA, context):
arguments.append('-nomd')
arguments.append(self.parameterAsRasterLayer(parameters, information.INPUT, context).source())
arguments.append(self.parameterAsRasterLayer(parameters, self.INPUT, context).source())
return ['gdalinfo', GdalUtils.escapeAndJoin(arguments)]

def processAlgorithm(self, parameters, context, feedback):
Expand Down
Loading

0 comments on commit 7c9d634

Please sign in to comment.