| pktools 2.6.7 Processing Kernel for geospatial data

pktoolsAlgorithmProvider.py
1# -*- coding: utf-8 -*-
2
3"""
4***************************************************************************
5 pktoolsAlgorithmProvider.py
6 ---------------------
7 Date : April 2015
8 Copyright : (C) 2015 by Pieter Kempeneers
9 Email : kempenep at gmail dot com
10***************************************************************************
11* *
12* This program is free software; you can redistribute it and/or modify *
13* it under the terms of the GNU General Public License as published by *
14* the Free Software Foundation; either version 2 of the License, or *
15* (at your option) any later version. *
16* *
17***************************************************************************
18"""
19
20__author__ = 'Pieter Kempeneers'
21__date__ = 'April 2015'
22__copyright__ = '(C) 2015, Pieter Kempeneers'
23# This will get replaced with a git SHA1 when you do a git archive
24__revision__ = '$Format:%H$'
25
26
27#from pktools.ExampleAlgorithm import ExampleAlgorithm
28#raster utilities
29 from pktools.pkcomposite import pkcomposite
30 from pktools.pkcrop import pkcrop
31 from pktools.pkreclass import pkreclass
32 from pktools.pkgetmask import pkgetmask
33 from pktools.pksetmask import pksetmask
34#raster/vector utilities
35 from pktools.pkextract import pkextract
36 from pktools.pkextract_grid import pkextract_grid
37 from pktools.pkextract_random import pkextract_random
38#Supervised classification utilities
39 from pktools.pksvm import pksvm
40 from pktools.pkdiff_accuracy import pkdiff_accuracy
41#LiDAR utilities
42 from pktools.pklas2img import pklas2img
43 from pktools.pkfilterdem import pkfilterdem
44#filter utilities
45 from pktools.pkfilter_spectral import pkfilter_spectral
46 from pktools.pkfilter_spatial import pkfilter_spatial
47
48 from processing.core.AlgorithmProvider import AlgorithmProvider
49 from processing.core.ProcessingConfig import Setting, ProcessingConfig
50 import os
51 from PyQt4 import QtGui
52 from pktools.pktoolsUtils import pktoolsUtils
53
54
55 class pktoolsAlgorithmProvider(AlgorithmProvider):
56
57 MY_DUMMY_SETTING = "MY_DUMMY_SETTING"
58
59 def __init__(self):
60 AlgorithmProvider.__init__(self)
61 # deactivate provider by default
62 self.activate = True
63 # load algorithms
64# self.alglist = [pkinfo()]
65 self.alglist = [pkreclass(),pkcrop(),pkcomposite(),pkgetmask(),pksetmask(),pkextract(),pkextract_grid(),pkextract_random(),pksvm(),pkdiff_accuracy(),pklas2img(),pkfilterdem(),pkfilter_spectral(),pkfilter_spatial()]
66 # pktools = [pkinfo()]
67 # for alg in pktools:
68 # alg.group = "pktools"
69 # self.alglist.extend(pktools)
70 for alg in self.alglist:
71 alg.provider = self
72
73 def initializeSettings(self):
74 '''In this method we add settings needed to configure our provider.
75 Do not forget to call the parent method, since it takes care or
76 automatically adding a setting for activating or deactivating the
77 algorithms in the provider
78 '''
79 AlgorithmProvider.initializeSettings(self)
80 ProcessingConfig.addSetting(Setting(self.getDescription(), pktoolsUtils.PKTOOLS_FOLDER, "pktools folder", pktoolsUtils.pktoolsPath()))
81
82# ProcessingConfig.addSetting(Setting("Example algorithms", pktoolsAlgorithmProvider.MY_DUMMY_SETTING, "Example setting", "Default value"))
83 # '''To get the parameter of a setting parameter, use
84# ProcessingConfig.getSetting(name_of_parameter)
85# '''
86
87 def unload(self):
88 '''Setting should be removed here, so they do not appear anymore
89 when the plugin is unloaded'''
90 AlgorithmProvider.unload(self)
91 ProcessingConfig.removeSetting(pktoolsAlgorithmProvider.MY_DUMMY_SETTING)
92
93 def getName(self):
94 '''This is the name that will appear on the toolbox group.
95 It is also used to create the command line name of all the algorithms
96 from this provider
97 '''
98 return "pktools"
99
100 def getDescription(self):
101 '''This is the provired full name.
102 '''
103 return "Utilities for remote sensing image processing"
104
105 def getIcon(self):
106 filepath = os.path.dirname(__file__) + "/logo.png"
107 return QtGui.QIcon(filepath)
108
109 def _loadAlgorithms(self):
110 '''Here we fill the list of algorithms in self.algs.
111 This method is called whenever the list of algorithms should be updated.
112 If the list of algorithms can change
113 (for instance, if it contains algorithms from user-defined scripts and
114 a new script might have been added), you should create the list again
115 here.
116 In this case, since the list is always the same, we assign from the pre-made list.
117 This assignment has to be done in this method even if the list does not change,
118 since the self.algs list is cleared before calling this method
119 '''
120 self.algs = self.alglist
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.alglist
alglist
Definition: pktoolsAlgorithmProvider.py:65
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.unload
def unload(self)
Definition: pktoolsAlgorithmProvider.py:87
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.activate
activate
Definition: pktoolsAlgorithmProvider.py:62
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.getDescription
def getDescription(self)
Definition: pktoolsAlgorithmProvider.py:100
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.getName
def getName(self)
Definition: pktoolsAlgorithmProvider.py:93
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.algs
algs
Definition: pktoolsAlgorithmProvider.py:120
qgis.pktoolsAlgorithmProvider.pktoolsAlgorithmProvider.initializeSettings
def initializeSettings(self)
Definition: pktoolsAlgorithmProvider.py:73