/
ogralgorithmprovider.py
60 lines (49 loc) · 2.67 KB
/
ogralgorithmprovider.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from sextante.core.AlgorithmProvider import AlgorithmProvider
from sextante.core.SextanteConfig import Setting, SextanteConfig
from ogrinfo import OgrInfo
from ogr2vrt import Ogr2Vrt
from ogr2ogr import Ogr2Ogr, Ogr2OgrVrt
from ogrsql import OgrSql
from ili2pg import Ili2Pg, Pg2Ili
from ilismeta import Ili2Imd, EnumsAsGML, ImportGML, IliEnumsToPg, CreatePGDb
class OgrAlgorithmProvider(AlgorithmProvider):
#MY_DUMMY_SETTING = "MY_DUMMY_SETTING"
def __init__(self):
AlgorithmProvider.__init__(self)
self.alglist = [OgrInfo(), Ogr2Vrt(), Ogr2Ogr(), Ogr2OgrVrt(), OgrSql(), Ili2Pg(), Pg2Ili(), Ili2Imd(), EnumsAsGML(), ImportGML(), IliEnumsToPg(), CreatePGDb()]
for alg in self.alglist:
alg.provider = self
def initializeSettings(self):
'''In this method we add settings needed to configure our provider.
Do not forget to call the parent method, since it takes care or
automatically adding a setting for activating or deactivating the
algorithms in the provider'''
AlgorithmProvider.initializeSettings(self)
#SextanteConfig.addSetting(Setting("Example algorithms", OgrAlgorithmProvider.MY_DUMMY_SETTING, "Example setting", "Default value"))
'''To get the parameter of a setting parameter, use SextanteConfig.getSetting(name_of_parameter)'''
def unload(self):
'''Setting should be removed here, so they do not appear anymore
when the plugin is unloaded'''
AlgorithmProvider.unload(self)
#SextanteConfig.removeSetting( OgrAlgorithmProvider.MY_DUMMY_SETTING)
def getName(self):
'''This is the name that will appear on the toolbox group.
It is also used to create the command line name of all the algorithms
from this provider'''
return "OGR"
def getIcon(self):
'''We return the default icon'''
return AlgorithmProvider.getIcon(self)
def getSupportedOutputVectorLayerExtensions(self):
return ["shp", "sqlite"]
def _loadAlgorithms(self):
'''Here we fill the list of algorithms in self.algs.
This method is called whenever the list of algorithms should be updated.
If the list of algorithms can change while executing SEXTANTE for QGIS
(for instance, if it contains algorithms from user-defined scripts and
a new script might have been added), you should create the list again
here.
In this case, since the list is always the same, we assign from the pre-made list.
This assignment has to be done in this method even if the list does not change,
since the self.algs list is cleared before calling this method'''
self.algs = self.alglist