Skip to content
Snippets Groups Projects
Commit 4ba1da7d authored by Julien Malik's avatar Julien Malik
Browse files

ENH: QGis - follow the moving API

parent bc95d8a4
No related branches found
No related tags found
No related merge requests found
...@@ -28,35 +28,61 @@ import processing ...@@ -28,35 +28,61 @@ import processing
import processing.parameters import processing.parameters
import otbApplication as otb import otbApplication as otb
class OTBPlugin(processing.Plugin): class OTBPlugin():
def __init__(self, iface): def __init__(self, iface):
apps = otb.Registry.GetAvailableApplications() self._modules = None
for app in apps: pass
processing.framework.registerModule([OTBModule(app)])
processing.Plugin.__init__(self, iface) def initGui(self):
processing.framework.registerModuleProvider(self)
def unload(self):
pass # TODO : unload the modules
def modules(self):
if self._modules is None:
apps = otb.Registry.GetAvailableApplications()
self._modules = set()
for app in apps:
self._modules.add(OTBModule(app))
return self._modules
class OTBModule(processing.Module): class OTBModule(processing.Module):
def __init__(self, modulename): def __init__(self, modulename):
self.app = otb.Registry.CreateApplication(modulename) self._app = otb.Registry.CreateApplication(modulename)
processing.Module.__init__(self, processing.Module.__init__(self,
self.app.GetName(), self._app.GetName(),
self.app.GetDescription()) self._app.GetDescription())
self._parameters = []
for p in self.app.GetParametersKeys(): for p in self._app.GetParametersKeys():
print p
self.addParameter(p) self.addParameter(p)
def addParameter(self, otbParamKey): def addParameter(self, otbParamKey):
otbToQGisParam = { otbToQGisParam = {
otb.ParameterType_Int: otb.ParameterType_Empty: processing.parameters.BooleanParameter,
processing.parameters.NumericParameter, otb.ParameterType_Int: processing.parameters.NumericParameter,
otb.ParameterType_Float: processing.parameters.NumericParameter,
otb.ParameterType_String: processing.parameters.StringParameter,
otb.ParameterType_Filename: processing.parameters.StringParameter,
otb.ParameterType_Directory: processing.parameters.StringParameter,
otb.ParameterType_Choice: processing.parameters.ChoiceParameter,
otb.ParameterType_InputImage: processing.parameters.StringParameter,
otb.ParameterType_InputComplexImage: processing.parameters.StringParameter,
otb.ParameterType_InputVectorData: processing.parameters.StringParameter,
otb.ParameterType_OutputImage: processing.parameters.StringParameter,
otb.ParameterType_OutputVectorData: processing.parameters.StringParameter,
otb.ParameterType_Radius: processing.parameters.NumericParameter
} }
name = otbParamKey name = otbParamKey
descr = self.app.GetParameterName(otbParamKey) descr = self._app.GetParameterName(otbParamKey)
typ = self.app.GetParameterType(otbParamKey) typ = self._app.GetParameterType(otbParamKey)
try: try:
qgisParam = otbToQGisParam[typ] qgisParam = otbToQGisParam[typ]
self._parameters.add(qgisParam(name, descr)) self._parameters.append(qgisParam(name, descr))
except KeyError: except KeyError:
#print name + " is of unhandled parameter type." #print name + " is of unhandled parameter type."
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment