diff --git a/Code/Wrappers/QgisProcessing/otb/CMakeLists.txt b/Code/Wrappers/QgisProcessing/otb/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7ffbe750ae4c6b1060a0d8456eebb293f5bdae1 --- /dev/null +++ b/Code/Wrappers/QgisProcessing/otb/CMakeLists.txt @@ -0,0 +1,8 @@ +FILE(GLOB INSTALLER_FILES *.py) +SET(INSTALLER_FILES ${INSTALLER_FILES}) + +ADD_CUSTOM_TARGET(otb ALL) + +INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/otb) + + diff --git a/Code/Wrappers/QgisProcessing/otb/__init__.py b/Code/Wrappers/QgisProcessing/otb/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..00e5178bd25c613d43dbb5f6b9b16761ad3b4d76 --- /dev/null +++ b/Code/Wrappers/QgisProcessing/otb/__init__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +# SAGA Modules plugin for Quantum GIS +# +# __init__.py (C) Camilo Polymeris +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +from plugin import OTBPlugin + +theOTBPlugin = None + +def name(): + return "Orfeo Toolbox Module interface" + +def description(): + return "Run the versatile OTB modules. OTB must be installed" + +def icon(): + return "saga.png" + +def version(): + return "Version 0.1" + +def qgisMinimumVersion(): + return "1.0" + +def authorName(): + return "Julien Malik" + +def classFactory(iface): + global theOTBPlugin + if not theOTBPlugin : + theOTBPlugin = OTBPlugin(iface) + return theOTBPlugin + diff --git a/Code/Wrappers/QgisProcessing/otb/plugin.py b/Code/Wrappers/QgisProcessing/otb/plugin.py new file mode 100644 index 0000000000000000000000000000000000000000..c76709422ea5cb9b09bd541e653437ef41ef0202 --- /dev/null +++ b/Code/Wrappers/QgisProcessing/otb/plugin.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- + +# SAGA Modules plugin for Quantum GIS +# +# plugin.py (C) Camilo Polymeris +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. + +from PyQt4.QtCore import * +from PyQt4.QtGui import * +from qgis.core import * + +import os +import processing +import processing.parameters +import otbApplication as otb + +class OTBPlugin(processing.Plugin): + def __init__(self, iface): + apps = otb.Registry.GetAvailableApplications() + for app in apps: + processing.framework.registerModule([OTBModule(app)]) + processing.Plugin.__init__(self, iface) + +class OTBModule(processing.Module): + def __init__(self, modulename): + self.app = otb.Registry.CreateApplication(modulename) + processing.Module.__init__(self, + self.app.GetName(), + self.app.GetDescription()) + + for p in self.app.GetParametersKeys(): + self.addParameter(p) + + def addParameter(self, otbParamKey): + otbToQGisParam = { + otb.ParameterType_Int: + processing.parameters.NumericParameter, + } + + name = otbParamKey + descr = self.app.GetParameterName(otbParamKey) + typ = self.app.GetParameterType(otbParamKey) + try: + qgisParam = otbToQGisParam[typ] + self._parameters.add(qgisParam(name, descr)) + except KeyError: + #print name + " is of unhandled parameter type." + pass + def parameters(self): + return self._parameters + def tags(self): + return processing.Module.tags(self) | set([processing.Tag('otb')]) + +