Beispiel #1
0
    def __init__(self):
        GeoAlgorithm.__init__(self)
        #the dialog where this model is being edited
        self.modelerdialog = None
        self.descriptionFile = None

        #Geoalgorithms in this model
        self.algs = []

        #parameters of Geoalgorithms in self.algs.
        #Each entry is a map with (paramname, paramvalue) values for algs[i].
        #paramvalues are instances of AlgorithmAndParameter
        self.algParameters = []

        #algorithms that each algorithm depends on.
        #This is just a list of dependencies not set by outputs and inputs
        #but explicitely entered instead, meaning that an algorithm must ''wait''
        #for another to finish
        #Each entry is a list with algorithm indexes
        self.dependencies = []

        #outputs of Geoalgorithms in self.algs.
        #Each entry is a map with (output, outputvalue) values for algs[i].
        #outputvalue is the name of the output if final. None if is an intermediate output
        self.algOutputs = []

        #Hardcoded parameter values entered by the user when defining the model. Keys are value names.
        self.paramValues = {}

        #position of items in canvas
        self.algPos = []
        self.paramPos = []

        #deactivated algorithms that should not be executed
        self.deactivated = []
Beispiel #2
0
    def __init__(self):
        GeoAlgorithm.__init__(self)
        # the dialog where this model is being edited
        self.modelerdialog = None
        self.descriptionFile = None

        # Geoalgorithms in this model
        self.algs = []

        # parameters of Geoalgorithms in self.algs.
        # Each entry is a map with (paramname, paramvalue) values for algs[i].
        # paramvalues are instances of AlgorithmAndParameter
        self.algParameters = []

        # outputs of Geoalgorithms in self.algs.
        # Each entry is a map with (output, outputvalue) values for algs[i].
        # outputvalue is the name of the output if final. None if is an intermediate output
        self.algOutputs = []

        # Hardcoded parameter values entered by the user when defining the model. Keys are value names.
        self.paramValues = {}

        # position of items in canvas
        self.algPos = []
        self.paramPos = []

        # deactivated algorithms that should not be executed
        self.deactivated = []
Beispiel #3
0
    def __init__(self):
        GeoAlgorithm.__init__(self)
        #the dialog where this model is being edited
        self.modelerdialog = None
        self.descriptionFile = None

        #Geoalgorithms in this model
        self.algs = []

        #parameters of Geoalgorithms in self.algs.
        #Each entry is a map with (paramname, paramvalue) values for algs[i].
        #paramvalues are instances of AlgorithmAndParameter
        self.algParameters = []

        #outputs of Geoalgorithms in self.algs.
        #Each entry is a map with (output, outputvalue) values for algs[i].
        #outputvalue is the name of the output if final. None if is an intermediate output
        self.algOutputs = []

        #Hardcoded parameter values entered by the user when defining the model. Keys are value names.
        self.paramValues = {}

        #position of items in canvas
        self.algPos = []
        self.paramPos = []

        #deactivated algorithms that should not be executed
        self.deactivated = []
    def __init__(self):
        GeoAlgorithm.__init__(self)
        #the dialog where this model is being edited
        self.modelerdialog = None
        self.descriptionFile = None

        #Geoalgorithms in this model
        self.algs = []

        #parameters of Geoalgorithms in self.algs.
        #Each entry is a map with (paramname, paramvalue) values for algs[i].
        #paramvalues are instances of AlgorithmAndParameter
        self.algParameters = []

        #algorithms that each algorithm depends on.
        #This is just a list of dependencies not set by outputs and inputs
        #but explicitely entered instead, meaning that an algorithm must ''wait''
        #for another to finish
        #Each entry is a list with algorithm indexes
        self.dependencies = []

        #outputs of Geoalgorithms in self.algs.
        #Each entry is a map with (output, outputvalue) values for algs[i].
        #outputvalue is the name of the output if final. None if is an intermediate output
        self.algOutputs = []

        #Hardcoded parameter values entered by the user when defining the model. Keys are value names.
        self.paramValues = {}

        #position of items in canvas
        self.algPos = []
        self.paramPos = []

        #deactivated algorithms that should not be executed
        self.deactivated = []
Beispiel #5
0
 def __init__(self, descriptionfile):
     GeoAlgorithm.__init__(self)
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
     self.numExportedLayers = 0
     #GRASS console output, needed to do postprocessing in case GRASS dumps results to the console
     self.consoleOutput = []
Beispiel #6
0
 def __init__(self, descriptionfile):
     GeoAlgorithm.__init__(self)
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
     self.numExportedLayers = 0
     #GRASS console output, needed to do postprocessing in case GRASS dumps results to the console
     self.consoleOutput = []
Beispiel #7
0
 def __init__(self, descriptionfile):
     GeoAlgorithm.__init__(self)
     self.roiFile = None
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
     self.numExportedLayers = 0
     self.hasROI = None
Beispiel #8
0
 def __init__(self, descriptionfile):
     GeoAlgorithm.__init__(self)
     self.roiFile = None
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
     self.numExportedLayers = 0
     self.hasROI = None;
Beispiel #9
0
 def __init__(self, descriptionFile, script=None):
     GeoAlgorithm.__init__(self)
     self.script = script
     self.descriptionFile = descriptionFile
     if script is not None:
         self.defineCharacteristicsFromScript()
     if descriptionFile is not None:
         self.defineCharacteristicsFromFile()
Beispiel #10
0
 def __init__(self, descriptionFile, script=None):
     GeoAlgorithm.__init__(self)
     self.script = script
     self.descriptionFile = descriptionFile
     if script is not None:
         self.defineCharacteristicsFromScript()
     if descriptionFile is not None:
         self.defineCharacteristicsFromFile()
 def __init__(self, descriptionfile):
     self.resample = True #True if it should resample
                          #in case several non-matching raster layers are used as input
     GeoAlgorithm.__init__(self)
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
     if self.resample:
         #reconsider resampling policy now that we know the input parameters
         self.resample = self.setResamplingPolicy()
 def __init__(self, descriptionfile):
     self.resample = True  #True if it should resample
     #in case several non-matching raster layers are used as input
     GeoAlgorithm.__init__(self)
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
     if self.resample:
         #reconsider resampling policy now that we know the input parameters
         self.resample = self.setResamplingPolicy()
Beispiel #13
0
 def __init__(self, descriptionFile, script=None):
     '''The script parameter can be used to directly pass the code of the script without a file.
     This is to be used from the script edition dialog, but should not be used in other cases'''
     GeoAlgorithm.__init__(self)
     self.script = script
     self.descriptionFile = descriptionFile
     if script is not None:
         self.defineCharacteristicsFromScript()
     if descriptionFile is not None:
         self.defineCharacteristicsFromFile()
 def __init__(self, descriptionFile, script=None):
     '''The script parameter can be used to directly pass the code of the script without a file.
     This is to be used from the script edition dialog, but should not be used in other cases'''
     GeoAlgorithm.__init__(self)
     self.script = script
     self.descriptionFile = descriptionFile
     if script is not None:
         self.defineCharacteristicsFromScript()
     if descriptionFile is not None:
         self.defineCharacteristicsFromFile()
    def getPostProcessingErrorMessage(self, wrongLayers):
        html = GeoAlgorithm.getPostProcessingErrorMessage(self, wrongLayers)
        msg = GrassUtils.checkGrassIsInstalled(True)
        html += ("<p>This algorithm requires GRASS to be run. A test to check if GRASS is correctly installed "
                "and configured in your system has been performed, with the following result:</p><ul><i>")
        if msg is None:
            html += "GRASS seems to be correctly installed and configured</i></li></ul>"
        else:
            html += msg + "</i></li></ul>"
            html += '<p><a href= "http://docs.qgis.org/2.0/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure GRASS to be used with SEXTANTE</p>'

        return html
 def __init__(self, alg):
     useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     name = alg.name
     if useCategories:
         icon = GeoAlgorithm.getDefaultIcon()
         group, subgroup, name = AlgorithmDecorator.getGroupsAndName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Beispiel #17
0
 def __init__(self, alg):
     useCategories = SextanteConfig.getSetting(
         SextanteConfig.USE_CATEGORIES)
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     name = alg.name
     if useCategories:
         icon = GeoAlgorithm.getDefaultIcon()
         group, subgroup, name = AlgorithmDecorator.getGroupsAndName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Beispiel #18
0
 def __init__(self, alg):
     settings = QSettings()
     useCategories = settings.value(SextanteToolbox.USE_CATEGORIES, type=bool)
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     name = alg.name
     if useCategories:
         icon = GeoAlgorithm.getDefaultIcon()
         group, subgroup, name = AlgorithmDecorator.getGroupsAndName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Beispiel #19
0
    def getPostProcessingErrorMessage(self, wrongLayers):
        html = GeoAlgorithm.getPostProcessingErrorMessage(self, wrongLayers)
        msg = SagaUtils.checkSagaIsInstalled(True)
        html += (
            "<p>This algorithm requires SAGA to be run. A test to check if SAGA is correctly installed "
            "and configured in your system has been performed, with the following result:</p><ul><i>"
        )
        if msg is None:
            html += "SAGA seems to be correctly installed and configured</li></ul>"
        else:
            html += msg + "</i></li></ul>"
            html += '<p><a href= "http://docs.qgis.org/2.0/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with SEXTANTE</p>'

        return html
Beispiel #20
0
 def __init__(self, alg):
     settings = QSettings()
     useCategories = settings.value(SextanteToolbox.USE_CATEGORIES,
                                    type=bool)
     QTreeWidgetItem.__init__(self)
     self.alg = alg
     icon = alg.getIcon()
     name = alg.name
     if useCategories:
         icon = GeoAlgorithm.getDefaultIcon()
         group, subgroup, name = AlgorithmDecorator.getGroupsAndName(alg)
     self.setIcon(0, icon)
     self.setToolTip(0, name)
     self.setText(0, name)
Beispiel #21
0
    def getPostProcessingErrorMessage(self, wrongLayers):
        html = GeoAlgorithm.getPostProcessingErrorMessage(self, wrongLayers)
        msg = RUtils.checkRIsInstalled(True)
        html += ("<p>This algorithm requires R to be run. A test to check if R is correctly installed "
                "and configured in your system has been performed, with the following result:</p><ul><i>")
        if msg is None:
            html += "GRASS seems to be correctly installed and configured</i></li></ul>"
            html += "<p>The script you have executed needs the following packages:</p><ul>"
            packages = RUtils.getRequiredPackages(self.script)
            for p in packages:
                html += '<li>' + p + '</li>'
            html += "</ul><p>Make sure they are installed in your R environment before trying to execute this script.</p>"
        else:
            html += msg + "</i></li></ul>"
            html += '<p><a href= "http://docs.qgis.org/2.0/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure R to be used with SEXTANTE</p>'

        return html
Beispiel #22
0
    def getPostProcessingErrorMessage(self, wrongLayers):
        html = GeoAlgorithm.getPostProcessingErrorMessage(self, wrongLayers)
        msg = RUtils.checkRIsInstalled(True)
        html += (
            "<p>This algorithm requires R to be run. A test to check if R is correctly installed "
            "and configured in your system has been performed, with the following result:</p><ul><i>"
        )
        if msg is None:
            html += "GRASS seems to be correctly installed and configured</i></li></ul>"
            html += "<p>The script you have executed needs the following packages:</p><ul>"
            packages = RUtils.getRequiredPackages(self.script)
            for p in packages:
                html += '<li>' + p + '</li>'
            html += "</ul><p>Make sure they are installed in your R environment before trying to execute this script.</p>"
        else:
            html += msg + "</i></li></ul>"
            html += '<p><a href= "http://docs.qgis.org/2.0/html/en/docs/user_manual/sextante/3rdParty.html">Click here</a> to know more about how to install and configure R to be used with SEXTANTE</p>'

        return html
Beispiel #23
0
 def __init__(self, descriptionfile):
     GeoAlgorithm.__init__(self)
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()
 def getAsCommand(self):
     if self.descriptionFile:
         return GeoAlgorithm.getAsCommand(self)
     else:
         return None
Beispiel #25
0
 def getIcon(self):
     return GeoAlgorithm.getIcon(self)
 def getIcon(self):
     return GeoAlgorithm.getIcon(self)
Beispiel #27
0
    def fillTreeUsingCategories(self):
        providersToExclude = ["model", "script"]
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        for providerName in Sextante.algs.keys():
            provider = Sextante.algs[providerName]
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not SextanteConfig.getSetting(name):
                continue
            if providerName in providersToExclude or len(
                    Providers.providers[providerName].actions) != 0:
                continue
            algs = provider.values()
            #add algorithms
            for alg in algs:
                if not alg.showInToolbox:
                    continue
                altgroup, altsubgroup, altname = AlgorithmDecorator.getGroupsAndName(
                    alg)
                if altgroup is None:
                    continue
                if text == "" or text.lower() in altname.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, "Geoalgorithms")
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for groupname, group in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for subgroupname, subgroup in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)

            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in Sextante.algs.keys():
            groups = {}
            provider = Sextante.algs[providerName]
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not SextanteConfig.getSetting(name):
                continue
            if providerName not in providersToExclude:
                continue
            algs = provider.values()
            #add algorithms
            for alg in algs:
                if not alg.showInToolbox:
                    continue
                if text == "" or text.lower() in alg.name.lower():
                    if alg.group in groups:
                        groupItem = groups[alg.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        groupItem.setText(0, alg.group)
                        groupItem.setToolTip(0, alg.group)
                        groups[alg.group] = groupItem
                    algItem = TreeAlgorithmItem(alg)
                    groupItem.addChild(algItem)

            actions = Sextante.actions[providerName]
            for action in actions:
                if text == "" or text.lower() in action.name.lower():
                    if action.group in groups:
                        groupItem = groups[action.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        groupItem.setText(0, action.group)
                        groups[action.group] = groupItem
                    algItem = TreeActionItem(action)
                    groupItem.addChild(algItem)

            if len(groups) > 0:
                providerItem = QTreeWidgetItem()
                providerItem.setText(
                    0,
                    Sextante.getProviderFromName(
                        providerName).getDescription())
                providerItem.setIcon(
                    0,
                    Sextante.getProviderFromName(providerName).getIcon())
                providerItem.setToolTip(0, providerItem.text(0))
                for groupItem in groups.values():
                    providerItem.addChild(groupItem)
                self.algorithmTree.addTopLevelItem(providerItem)

        if (text != ""):
            self.algorithmTree.expandAll()
Beispiel #28
0
 def __init__(self, process, bookmark=False):
     self.process = process
     self.bookmark = bookmark
     GeoAlgorithm.__init__(self)  #calls defineCharacteristics
    def fillTreeUsingCategories(self):
        providersToExclude = ["model", "script"]
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        groups = {}
        for providerName in Sextante.algs.keys():
            provider = Sextante.algs[providerName]
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not SextanteConfig.getSetting(name):
                continue
            if providerName in providersToExclude or len(Providers.providers[providerName].actions) != 0:
                continue
            algs = provider.values()
            #add algorithms
            for alg in algs:
                if not alg.showInToolbox:
                    continue
                altgroup, altsubgroup, altname = AlgorithmDecorator.getGroupsAndName(alg)
                if altgroup is None:
                    continue
                if text =="" or text.lower() in altname.lower():
                    if altgroup not in groups:
                        groups[altgroup] = {}
                    group = groups[altgroup]
                    if altsubgroup not in group:
                        groups[altgroup][altsubgroup] = []
                    subgroup = groups[altgroup][altsubgroup]
                    subgroup.append(alg)

        if len(groups) > 0:
            mainItem = QTreeWidgetItem()
            mainItem.setText(0, "Geoalgorithms")
            mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
            mainItem.setToolTip(0, mainItem.text(0))
            for groupname, group in groups.items():
                groupItem = QTreeWidgetItem()
                groupItem.setText(0, groupname)
                groupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                groupItem.setToolTip(0, groupItem.text(0))
                mainItem.addChild(groupItem)
                for subgroupname, subgroup in group.items():
                    subgroupItem = QTreeWidgetItem()
                    subgroupItem.setText(0, subgroupname)
                    subgroupItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
                    subgroupItem.setToolTip(0, subgroupItem.text(0))
                    groupItem.addChild(subgroupItem)
                    for alg in subgroup:
                        algItem = TreeAlgorithmItem(alg)
                        subgroupItem.addChild(algItem)

            self.algorithmTree.addTopLevelItem(mainItem)

        for providerName in Sextante.algs.keys():
            groups = {}
            provider = Sextante.algs[providerName]
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not SextanteConfig.getSetting(name):
                continue
            if providerName not in providersToExclude:
                continue
            algs = provider.values()
            #add algorithms
            for alg in algs:
                if not alg.showInToolbox:
                    continue
                if text =="" or text.lower() in alg.name.lower():
                    if alg.group in groups:
                        groupItem = groups[alg.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        groupItem.setText(0, alg.group)
                        groupItem.setToolTip(0, alg.group)
                        groups[alg.group] = groupItem
                    algItem = TreeAlgorithmItem(alg)
                    groupItem.addChild(algItem)

            actions = Sextante.actions[providerName]
            for action in actions:
                if text =="" or text.lower() in action.name.lower():
                    if action.group in groups:
                        groupItem = groups[action.group]
                    else:
                        groupItem = QTreeWidgetItem()
                        groupItem.setText(0,action.group)
                        groups[action.group] = groupItem
                    algItem = TreeActionItem(action)
                    groupItem.addChild(algItem)

            if len(groups) > 0:
                providerItem = QTreeWidgetItem()
                providerItem.setText(0, Sextante.getProviderFromName(providerName).getDescription())
                providerItem.setIcon(0, Sextante.getProviderFromName(providerName).getIcon())
                providerItem.setToolTip(0, providerItem.text(0))
                for groupItem in groups.values():
                    providerItem.addChild(groupItem)
                self.algorithmTree.addTopLevelItem(providerItem)

        if (text != ""):
            self.algorithmTree.expandAll()
Beispiel #30
0
 def getAsCommand(self):
     if self.descriptionFile:
         return GeoAlgorithm.getAsCommand(self)
     else:
         return None
 def __init__(self, process, bookmark = False):
     self.process = process
     self.bookmark = bookmark
     GeoAlgorithm.__init__(self) #calls defineCharacteristics
 def __init__(self, descriptionfile):
     GeoAlgorithm.__init__(self)
     self.descriptionFile = descriptionfile
     self.defineCharacteristicsFromFile()