Commit a1762b73 authored by Rashad Kanavath's avatar Rashad Kanavath

respect naming conventions for qgis providers

parent 57fb661d
......@@ -23,11 +23,11 @@ __copyright__ = '(C) 2017 Boundless, http://boundlessgeo.com'
# This will get replaced with a git SHA1 when you do a git archive
from qgis.core import QgsApplication
from .OTBAlgorithmProvider import OTBAlgorithmProvider
from .OtbAlgorithmProvider import OtbAlgorithmProvider
class OTBPlugin:
def __init__(self):
self.provider = OTBAlgorithmProvider()
self.provider = OtbAlgorithmProvider()
def initGui(self):
QgsApplication.processingRegistry().addProvider(self.provider)
......
# -*- coding: utf-8 -*-
"""
***************************************************************************
OTBAlgorithm.py
OtbAlgorithm.py
---------------
Date : June 2017
Copyright : (C) 2017 by CS Systemes d'Information (CS SI)
......@@ -46,10 +46,10 @@ from qgis.core import (Qgis,
from processing.core.parameters import getParameterFromString
from otb.OTBChoiceWidget import OTBParameterChoice
from otb import OTBUtils
from otb.OtbChoiceWidget import OtbParameterChoice
from otb import OtbUtils
class OTBAlgorithm(QgsProcessingAlgorithm):
class OtbAlgorithm(QgsProcessingAlgorithm):
def __init__(self, group, name, descriptionfile, display_name='', groupId=''):
super().__init__()
self._name = name
......@@ -90,7 +90,7 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
return self.__class__(self._group, self._name, self._descriptionfile)
def tr(self, string):
return QCoreApplication.translate("OTBAlgorithm", string)
return QCoreApplication.translate("OtbAlgorithm", string)
def name(self):
return self._name
......@@ -110,7 +110,7 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
def initAlgorithm(self, config=None):
pass
#TODO: show version which is same as OTBAlgorithm rather than always latest.
#TODO: show version which is same as OtbAlgorithm rather than always latest.
def helpUrl(self):
return "https://www.orfeo-toolbox.org/CookBook/Applications/app_" + self.name() + ".html"
......@@ -123,14 +123,14 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
self.appkey = self._name
line = lines.readline().strip('\n').strip()
self.doc = line
self.i18n_doc = QCoreApplication.translate("OTBAlgorithm", self.doc)
self.i18n_doc = QCoreApplication.translate("OtbAlgorithm", self.doc)
#self._name = self._name #+ " - " + self.doc
self._display_name = self.tr(self._name)
self.i18n_name = QCoreApplication.translate("OTBAlgorithm", self._name)
self.i18n_name = QCoreApplication.translate("OtbAlgorithm", self._name)
line = lines.readline().strip('\n').strip()
self._group = line
self.i18n_group = QCoreApplication.translate("OTBAlgorithm", self._group)
self.i18n_group = QCoreApplication.translate("OtbAlgorithm", self._group)
line = lines.readline().strip('\n').strip()
while line != '':
line = line.strip('\n').strip()
......@@ -142,7 +142,7 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
tokens = line.split("|")
params = [t if str(t) != str(None) else None for t in tokens[1:]]
options = params[2].split(';')
param = OTBParameterChoice(params[0], params[1], options, params[3], params[4])
param = OtbParameterChoice(params[0], params[1], options, params[3], params[4])
else:
param = getParameterFromString(line)
......@@ -167,9 +167,9 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
#Future releases of OTB must follow this rule keep
#compatibility or update this checklist.
if name in ["elev.dem.path", "elev.dem"]:
param.setDefaultValue(OTBUtils.srtmFolder())
param.setDefaultValue(OtbUtils.srtmFolder())
if name in ["elev.dem.geoid", "elev.geoid"]:
param.setDefaultValue(OTBUtils.geoidFile())
param.setDefaultValue(OtbUtils.geoidFile())
self.addParameter(param)
#parameter is added now and we must move to next line
......@@ -226,8 +226,8 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
def processAlgorithm(self, parameters, context, feedback):
output_key = self.outputParameterName()
otb_cli_file = OTBUtils.cliPath()
command = '"{}" {} {}'.format(otb_cli_file, self.name(), OTBUtils.appFolder())
otb_cli_file = OtbUtils.cliPath()
command = '"{}" {} {}'.format(otb_cli_file, self.name(), OtbUtils.appFolder())
for k, v in parameters.items():
if k == 'outputpixeltype' or not v:
continue
......@@ -255,7 +255,7 @@ class OTBAlgorithm(QgsProcessingAlgorithm):
import errno
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), otb_cli_file)
OTBUtils.executeOtb(command, feedback)
OtbUtils.executeOtb(command, feedback)
result = {}
for out in self.destinationParameterDefinitions():
......
# -*- coding: utf-8 -*-
"""
***************************************************************************
OTBChoiceWidget.py
OtbChoiceWidget.py
------------------
Date : June 2017
Copyright : (C) 2017 by CS Systemes d'Information (CS SI)
......@@ -33,7 +33,7 @@ from processing.gui.wrappers import (WidgetWrapper,
DIALOG_BATCH,
DIALOG_MODELER)
class OTBChoiceWidgetWrapper(WidgetWrapper):
class OtbChoiceWidgetWrapper(WidgetWrapper):
def createWidget(self):
widget = QComboBox()
widget.addItems(self.param.options)
......@@ -125,7 +125,7 @@ class OTBChoiceWidgetWrapper(WidgetWrapper):
from qgis.core import QgsProcessingParameterDefinition
class OTBParameterChoice(QgsProcessingParameterDefinition):
class OtbParameterChoice(QgsProcessingParameterDefinition):
def __init__(self, name='', description='', options=[], default=None, isSource=False,
multiple=False, optional=False):
......@@ -134,7 +134,7 @@ class OTBParameterChoice(QgsProcessingParameterDefinition):
self.setMetadata({
'widget_wrapper': {
'class': 'otb.OTBChoiceWidget.OTBChoiceWidgetWrapper'}})
'class': 'otb.OtbChoiceWidget.OtbChoiceWidgetWrapper'}})
self.options = options
if default is not None:
......@@ -152,5 +152,6 @@ class OTBParameterChoice(QgsProcessingParameterDefinition):
return True
def type(self):
#This value is written by otbQgisDescriptor.
return 'OTBParameterChoice'
......@@ -18,9 +18,9 @@ __copyright__ = '(C) CNES 2019'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
class OTBSettings(object):
class OtbSettings(object):
"""
OTBSetting's key names
OtbSetting's key names
"""
# Checkbox to enable/disable otb provider (bool).
ACTIVATE = "OTB_ACTIVATE"
......@@ -50,11 +50,11 @@ class OTBSettings(object):
@staticmethod
def keys():
return [
OTBSettings.ACTIVATE,
OTBSettings.FOLDER,
OTBSettings.SRTM_FOLDER,
OTBSettings.GEOID_FILE,
OTBSettings.LOGGER_LEVEL,
OTBSettings.MAX_RAM_HINT
OtbSettings.ACTIVATE,
OtbSettings.FOLDER,
OtbSettings.SRTM_FOLDER,
OtbSettings.GEOID_FILE,
OtbSettings.LOGGER_LEVEL,
OtbSettings.MAX_RAM_HINT
]
......@@ -2,8 +2,8 @@
"""
***************************************************************************
OTBUtils.py
---------------------
OtbUtils.py
-----------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
(C) 2013 by CS Systemes d'information (CS SI)
......@@ -12,6 +12,7 @@
Contributors : Victor Olaya
Julien Malik, Oscar Picas (CS SI) - add functions to manage xml tree
Alexia Mondot (CS SI) - add a trick for OTBApplication SplitImages
Rashad Kanavath (CS SI) - re-integration of provider to QGIS
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -36,39 +37,39 @@ import subprocess
from processing.core.ProcessingConfig import ProcessingConfig
from qgis.core import (Qgis, QgsApplication, QgsMessageLog)
from qgis.PyQt.QtCore import QCoreApplication
from otb.OTBSettings import OTBSettings
from otb.OtbSettings import OtbSettings
def cliPath():
cli_ext = '.bat' if os.name == 'nt' else ''
return os.path.normpath(os.path.join(QgsApplication.qgisSettingsDirPath(),
'processing', 'qgis_otb_cli' + cli_ext))
def version():
return ProcessingConfig.getSetting(OTBSettings.VERSION) or '0.0.0'
return ProcessingConfig.getSetting(OtbSettings.VERSION) or '0.0.0'
def loggerLevel():
return ProcessingConfig.getSetting(OTBSettings.LOGGER_LEVEL) or 'INFO'
return ProcessingConfig.getSetting(OtbSettings.LOGGER_LEVEL) or 'INFO'
def maxRAMHint():
return ProcessingConfig.getSetting(OTBSettings.MAX_RAM_HINT) or ''
return ProcessingConfig.getSetting(OtbSettings.MAX_RAM_HINT) or ''
def otbFolder():
if ProcessingConfig.getSetting(OTBSettings.FOLDER):
return os.path.normpath(os.sep.join(re.split(r'\\|/', ProcessingConfig.getSetting(OTBSettings.FOLDER))))
if ProcessingConfig.getSetting(OtbSettings.FOLDER):
return os.path.normpath(os.sep.join(re.split(r'\\|/', ProcessingConfig.getSetting(OtbSettings.FOLDER))))
else:
return None
def appFolder():
app_folder = ProcessingConfig.getSetting(OTBSettings.APP_FOLDER)
app_folder = ProcessingConfig.getSetting(OtbSettings.APP_FOLDER)
if app_folder:
return os.pathsep.join(app_folder.split(';'))
else:
return None
def srtmFolder():
return ProcessingConfig.getSetting(OTBSettings.SRTM_FOLDER) or ''
return ProcessingConfig.getSetting(OtbSettings.SRTM_FOLDER) or ''
def geoidFile():
return ProcessingConfig.getSetting(OTBSettings.GEOID_FILE) or ''
return ProcessingConfig.getSetting(OtbSettings.GEOID_FILE) or ''
def executeOtb(commands, feedback, addToLog=True):
loglines = []
......@@ -116,5 +117,5 @@ def executeOtb(commands, feedback, addToLog=True):
def tr(string, context=''):
if context == '':
context = 'OTBUtils'
context = 'OtbUtils'
return QCoreApplication.translate(context, string)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment