Esempio n. 1
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     if OTBUtils.findOtbPath() is None:
         ProcessingConfig.addSetting(
             Setting(self.getDescription(),
                     OTBUtils.OTB_FOLDER,
                     self.tr("OTB command line tools folder"),
                     OTBUtils.otbPath(),
                     valuetype=Setting.FOLDER))
     if OTBUtils.findOtbLibPath() is None:
         ProcessingConfig.addSetting(
             Setting(self.getDescription(),
                     OTBUtils.OTB_LIB_FOLDER,
                     self.tr("OTB applications folder"),
                     OTBUtils.otbLibPath(),
                     valuetype=Setting.FOLDER))
     ProcessingConfig.addSetting(
         Setting(self.getDescription(),
                 OTBUtils.OTB_SRTM_FOLDER,
                 self.tr("SRTM tiles folder"),
                 OTBUtils.otbSRTMPath(),
                 valuetype=Setting.FOLDER))
     ProcessingConfig.addSetting(
         Setting(self.getDescription(),
                 OTBUtils.OTB_GEOID_FILE,
                 self.tr("Geoid file"),
                 OTBUtils.otbGeoidPath(),
                 valuetype=Setting.FOLDER))
Esempio n. 2
0
    def defineCharacteristicsFromFile(self):
        content = open(self.descriptionFile).read()
        dom_model = ET.fromstring(content)

        self.appkey = dom_model.find('key').text
        self.cliName = dom_model.find('exec').text
        self.name = dom_model.find('longname').text
        self.i18n_name = QCoreApplication.translate("OTBAlgorithm", self.name)
        self.group = dom_model.find('group').text
        self.i18n_group = QCoreApplication.translate("OTBAlgorithm", self.group)

        rebu = None
        the_result = None

        try:
            rebu = self.get_list_from_node(dom_model)
            the_result = map(self.adapt_list_to_string, rebu)
        except Exception as e:
            ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                                   self.tr('Could not open OTB algorithm: %s\n%s' % (self.descriptionFile, traceback.format_exc())))
            raise e

        for line in the_result:
            try:
                if line.startswith("Parameter") or line.startswith("*Parameter"):
                    if line.startswith("*Parameter"):
                        param = getParameterFromString(line[1:])
                        param.isAdvanced = True
                    else:
                        param = getParameterFromString(line)
                    # Hack for initializing the elevation parameters from Processing configuration
                    if param.name == "-elev.dem.path" or param.name == "-elev.dem" or "elev.dem" in param.name:
                        param.default = OTBUtils.otbSRTMPath()
                    elif param.name == "-elev.dem.geoid" or param.name == "-elev.geoid" or "elev.geoid" in param.name:
                        param.default = OTBUtils.otbGeoidPath()
                    self.addParameter(param)
                elif line.startswith("Extent"):
                    self.addParameter(ParameterExtent(self.REGION_OF_INTEREST, "Region of interest", "0,1,0,1"))
                    self.hasROI = True
                else:
                    self.addOutput(getOutputFromString(line))
            except Exception as e:
                ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                                       self.tr('Could not open OTB algorithm: %s\n%s' % (self.descriptionFile, line)))
                raise e
Esempio n. 3
0
 def initializeSettings(self):
     AlgorithmProvider.initializeSettings(self)
     ProcessingConfig.addSetting(Setting(self.getDescription(),
                                         OTBUtils.OTB_FOLDER,
                                         self.tr("OTB command line tools folder"), OTBUtils.findOtbPath(),
                                         valuetype=Setting.FOLDER))
     ProcessingConfig.addSetting(Setting(self.getDescription(),
                                         OTBUtils.OTB_LIB_FOLDER,
                                         self.tr("OTB applications folder"), OTBUtils.findOtbLibPath(),
                                         valuetype=Setting.FOLDER))
     ProcessingConfig.addSetting(Setting(self.getDescription(),
                                         OTBUtils.OTB_SRTM_FOLDER,
                                         self.tr("SRTM tiles folder"), OTBUtils.otbSRTMPath(),
                                         valuetype=Setting.FOLDER))
     ProcessingConfig.addSetting(Setting(self.getDescription(),
                                         OTBUtils.OTB_GEOID_FILE,
                                         self.tr("Geoid file"), OTBUtils.otbGeoidPath(),
                                         valuetype=Setting.FOLDER))