Skip to content

Commit

Permalink
[processing] all gdal algs now have the same icon
Browse files Browse the repository at this point in the history
Did some code cleaning in gdal package
  • Loading branch information
volaya committed Jun 2, 2014
1 parent 45c0be1 commit 4eab185
Show file tree
Hide file tree
Showing 54 changed files with 74 additions and 233 deletions.
5 changes: 1 addition & 4 deletions python/plugins/processing/algs/gdal/CMakeLists.txt
@@ -1,8 +1,5 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB ICON_FILES icons/*.png)

ADD_SUBDIRECTORY(scripts)
ADD_SUBDIRECTORY(pyogr)

PLUGIN_INSTALL(processing ./algs/gdal ${PY_FILES})
PLUGIN_INSTALL(processing ./algs/gdal/icons ${ICON_FILES})
PLUGIN_INSTALL(processing ./algs/gdal ${PY_FILES})
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/ClipByExtent.py
Expand Up @@ -29,7 +29,7 @@
from PyQt4 import QtGui
from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm

from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterExtent import ParameterExtent
Expand All @@ -39,18 +39,14 @@
from processing.algs.gdal.GdalUtils import GdalUtils


class ClipByExtent(GeoAlgorithm):
class ClipByExtent(GdalAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
NO_DATA = 'NO_DATA'
PROJWIN = 'PROJWIN'
EXTRA = 'EXTRA'

def getIcon(self):
filepath = os.path.dirname(__file__) + '/icons/raster-clip.png'
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Clip raster by extent'
self.group = '[GDAL] Extraction'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/ClipByMask.py
Expand Up @@ -30,7 +30,7 @@
from osgeo import gdal
from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm

from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterVector import ParameterVector
Expand All @@ -42,7 +42,7 @@
from processing.algs.gdal.GdalUtils import GdalUtils


class ClipByMask(GeoAlgorithm):
class ClipByMask(GdalAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
Expand All @@ -52,10 +52,6 @@ class ClipByMask(GeoAlgorithm):
KEEP_RESOLUTION = 'KEEP_RESOLUTION'
EXTRA = 'EXTRA'

def getIcon(self):
filepath = os.path.dirname(__file__) + '/icons/raster-clip.png'
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Clip raster by mask layer'
self.group = '[GDAL] Extraction'
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/ColorRelief.py
Expand Up @@ -28,7 +28,7 @@

from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterBoolean import ParameterBoolean
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -39,7 +39,7 @@
from processing.tools.system import *


class ColorRelief(GeoAlgorithm):
class ColorRelief(GdalAlgorithm):

INPUT = 'INPUT'
BAND = 'BAND'
Expand Down
15 changes: 8 additions & 7 deletions python/plugins/processing/algs/gdal/GdalAlgorithm.py
Expand Up @@ -28,14 +28,15 @@
import os
from PyQt4 import QtGui
from processing.script.ScriptAlgorithm import ScriptAlgorithm
from processing.core.GeoAlgorithm import GeoAlgorithm


class GdalAlgorithm(ScriptAlgorithm):
"""Just a ScriptAlgorithm that automatically takes its icon
filename for the script filename.
"""
class GdalAlgorithm(GeoAlgorithm):

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + '/../../images/gdal.png')

class GdalScriptAlgorithm(ScriptAlgorithm):

def getIcon(self):
filename = os.path.basename(self.descriptionFile[:-2] + 'png')
filepath = os.path.dirname(__file__) + '/icons/' + filename
return QtGui.QIcon(filepath)
return QtGui.QIcon(os.path.dirname(__file__) + '/../../images/gdal.png')
Expand Up @@ -32,8 +32,7 @@
from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingLog import ProcessingLog
from processing.script.WrongScriptException import WrongScriptException

from GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalScriptAlgorithm
from GdalUtils import GdalUtils

from nearblack import nearblack
Expand Down Expand Up @@ -103,7 +102,7 @@ def getName(self):
return 'gdalogr'

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/icons/gdalicon.png')
return QIcon(os.path.dirname(__file__) + '/../../images/gdal.png')

def _loadAlgorithms(self):
self.algs = self.preloadedAlgs
Expand Down Expand Up @@ -131,7 +130,7 @@ def createAlgsList(self):
try:
fullpath = os.path.join(self.scriptsFolder(),
descriptionFile)
alg = GdalAlgorithm(fullpath)
alg = GdalScriptAlgorithm(fullpath)
self.preloadedAlgs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/GridAverage.py
Expand Up @@ -28,7 +28,7 @@

from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterTableField import ParameterTableField
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -37,7 +37,7 @@
from processing.tools.system import *


class GridAverage(GeoAlgorithm):
class GridAverage(GdalAlgorithm):

INPUT = 'INPUT'
Z_FIELD = 'Z_FIELD'
Expand All @@ -48,10 +48,6 @@ class GridAverage(GeoAlgorithm):
NODATA = 'NODATA'
OUTPUT = 'OUTPUT'

#def getIcon(self):
# filepath = os.path.dirname(__file__) + '/icons/dem.png'
# return QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Grid (Moving average)'
self.group = '[GDAL] Analysis'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/GridDataMetrics.py
Expand Up @@ -28,7 +28,7 @@

from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterTableField import ParameterTableField
from processing.parameters.ParameterSelection import ParameterSelection
Expand All @@ -38,7 +38,7 @@
from processing.tools.system import *


class GridDataMetrics(GeoAlgorithm):
class GridDataMetrics(GdalAlgorithm):

INPUT = 'INPUT'
Z_FIELD = 'Z_FIELD'
Expand All @@ -53,10 +53,6 @@ class GridDataMetrics(GeoAlgorithm):
DATA_METRICS = ['Minimum', 'Maximum', 'Range', 'Count', 'Average distance',
'Average distance between points']

#def getIcon(self):
# filepath = os.path.dirname(__file__) + '/icons/dem.png'
# return QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Grid (Data metrics)'
self.group = '[GDAL] Analysis'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/GridInvDist.py
Expand Up @@ -28,7 +28,7 @@

from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterTableField import ParameterTableField
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -37,7 +37,7 @@
from processing.tools.system import *


class GridInvDist(GeoAlgorithm):
class GridInvDist(GdalAlgorithm):

INPUT = 'INPUT'
Z_FIELD = 'Z_FIELD'
Expand All @@ -51,10 +51,6 @@ class GridInvDist(GeoAlgorithm):
NODATA = 'NODATA'
OUTPUT = 'OUTPUT'

#def getIcon(self):
# filepath = os.path.dirname(__file__) + '/icons/dem.png'
# return QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Grid (Inverse distance to a power)'
self.group = '[GDAL] Analysis'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/GridNearest.py
Expand Up @@ -28,7 +28,7 @@

from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterTableField import ParameterTableField
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -37,7 +37,7 @@
from processing.tools.system import *


class GridNearest(GeoAlgorithm):
class GridNearest(GdalAlgorithm):

INPUT = 'INPUT'
Z_FIELD = 'Z_FIELD'
Expand All @@ -47,10 +47,6 @@ class GridNearest(GeoAlgorithm):
NODATA = 'NODATA'
OUTPUT = 'OUTPUT'

#def getIcon(self):
# filepath = os.path.dirname(__file__) + '/icons/dem.png'
# return QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Grid (Nearest neighbor)'
self.group = '[GDAL] Analysis'
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/OgrAlgorithm.py
Expand Up @@ -38,11 +38,11 @@
from PyQt4.QtGui import *
from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.tools import dataobjects


class OgrAlgorithm(GeoAlgorithm):
class OgrAlgorithm(GdalAlgorithm):

DB = 'DB'

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/aspect.py
Expand Up @@ -28,7 +28,7 @@

from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterBoolean import ParameterBoolean
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -37,7 +37,7 @@
from processing.tools.system import *


class aspect(GeoAlgorithm):
class aspect(GdalAlgorithm):

INPUT = 'INPUT'
BAND = 'BAND'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/contour.py
Expand Up @@ -29,7 +29,7 @@
from PyQt4 import QtGui
from qgis.core import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm

from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -40,18 +40,14 @@
from processing.algs.gdal.GdalUtils import GdalUtils


class contour(GeoAlgorithm):
class contour(GdalAlgorithm):

INPUT_RASTER = 'INPUT_RASTER'
OUTPUT_VECTOR = 'OUTPUT_VECTOR'
INTERVAL = 'INTERVAL'
FIELD_NAME = 'FIELD_NAME'
EXTRA = 'EXTRA'

def getIcon(self):
filepath = os.path.dirname(__file__) + '/icons/contour.png'
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Contour'
self.group = '[GDAL] Extraction'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/extractprojection.py
Expand Up @@ -30,20 +30,16 @@
from osgeo import gdal, osr
from PyQt4.QtGui import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterBoolean import ParameterBoolean


class ExtractProjection(GeoAlgorithm):
class ExtractProjection(GdalAlgorithm):

INPUT = 'INPUT'
PRJ_FILE = 'PRJ_FILE'

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/icons/projection-export.png'
)

def defineCharacteristics(self):
self.name = 'Extract projection'
self.group = '[GDAL] Projections'
Expand Down
10 changes: 2 additions & 8 deletions python/plugins/processing/algs/gdal/fillnodata.py
Expand Up @@ -25,10 +25,8 @@

__revision__ = '$Format:%H$'

import os
from PyQt4 import QtGui, QtCore

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm

from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -40,7 +38,7 @@
from processing.algs.gdal.GdalUtils import GdalUtils


class fillnodata(GeoAlgorithm):
class fillnodata(GdalAlgorithm):

INPUT = 'INPUT'
DISTANCE = 'DISTANCE'
Expand All @@ -50,10 +48,6 @@ class fillnodata(GeoAlgorithm):
NO_DEFAULT_MASK = 'NO_DEFAULT_MASK'
OUTPUT = 'OUTPUT'

#def getIcon(self):
# filepath = os.path.dirname(__file__) + '/icons/fillnodata.png'
# return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = 'Fill nodata'
self.group = '[GDAL] Analysis'
Expand Down
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/gdal2xyz.py
Expand Up @@ -25,11 +25,10 @@

__revision__ = '$Format:%H$'

import os
from PyQt4.QtGui import *
from PyQt4.QtCore import *

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm

from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterNumber import ParameterNumber
Expand All @@ -40,15 +39,12 @@
from processing.algs.gdal.GdalUtils import GdalUtils


class gdal2xyz(GeoAlgorithm):
class gdal2xyz(GdalAlgorithm):

INPUT = 'INPUT'
BAND = 'BAND'
OUTPUT = 'OUTPUT'

#def getIcon(self):
# return QIcon(os.path.dirname(__file__) + "/icons/gdal2xyz.png")

def defineCharacteristics(self):
self.name = 'gdal2xyz'
self.group = '[GDAL] Conversion'
Expand Down

0 comments on commit 4eab185

Please sign in to comment.