• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python Sextante.Sextante类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sextante.core.Sextante.Sextante的典型用法代码示例。如果您正苦于以下问题:Python Sextante类的具体用法?Python Sextante怎么用?Python Sextante使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Sextante类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: initGui

  def initGui(self):
 
    # Create action that will start plugin configuration
     self.action = QAction(QIcon(":/plugins/QgsWPSClient/images/wps-add.png"), "QgsWPSClient", self.iface.mainWindow())
     self.action.triggered.connect(self.run)
     
     self.actionAbout = QAction("About", self.iface.mainWindow())
     self.actionAbout.triggered.connect(self.doAbout)
         
    # Add toolbar button and menu item
     self.iface.addToolBarIcon(self.action)
     
     if hasattr(self.iface,  "addPluginToWebMenu"):
         self.iface.addPluginToWebMenu("QgsWPSClient", self.action)
         self.iface.addPluginToWebMenu("QgsWPSClient", self.actionAbout)
     else:
         self.iface.addPluginToMenu("QgsWPSClient", self.action)
         self.iface.addPluginToWebMenu("QgsWPSClient", self.action)

     
     self.myDockWidget = QgsWpsDockWidget(self.iface)
     self.myDockWidget.setWindowTitle('QgsWPSClient-'+version())
     self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.myDockWidget)
     self.myDockWidget.show()

     if SEXTANTE_SUPPORT:
         self.provider = WpsAlgorithmProvider(self.myDockWidget)
     else:
         self.provider = None

     if self.provider:
        try:
            Sextante.addProvider(self.provider, True) #Force tree update
        except TypeError:
            Sextante.addProvider(self.provider)
开发者ID:maelocrowd,项目名称:QGis_plugin,代码行数:35,代码来源:qgswps.py


示例2: createTest

def createTest(text):
    s = ""
    tokens =  text[len("sextante.runalg("):-1].split(",")
    cmdname = tokens[0][1:-1];
    methodname = "test_" + cmdname.replace(":","")
    s += "def " + methodname + "(self):\n"
    alg = Sextante.getAlgorithm(cmdname)
    execcommand = "sextante.runalg("
    i = 0
    for token in tokens:
        if i < alg.getVisibleParametersCount() + 1:                            
            if os.path.exists(token[1:-1]):
                token = os.path.basename(token[1:-1])[:-4]           
            execcommand += token + "(),"
        else:
            execcommand += "None,"
        i+=1
    s += "\toutputs=" + execcommand[:-1] + ")\n"

    i = -1 * len(alg.outputs)
    for out in alg.outputs:        
        filename = tokens[i][1:-1]
        if (filename == str(None)):
            raise Exception("Cannot create unit test for that algorithm execution.\nThe output cannot be a temporary file")        
        s+="\toutput=outputs['" + out.name + "']\n"
        if isinstance(out, (OutputNumber, OutputString)):
            s+="self.assertTrue(" + str(out) + ", output)\n"
        if isinstance(out, OutputRaster):
            dataset = gdal.Open(filename, GA_ReadOnly)
            array = dataset.ReadAsArray(1)
            s+="\tself.assertTrue(os.path.isfile(output))\n"
            s+="\tself.assertEqual(hashraster(output)," + str(hash(array)) + ")\n"
        if isinstance(out, OutputVector):
            layer = Sextante.getObject(filename)
            fields = layer.pendingFields()
            s+="\tlayer=QGisLayers.getObjectFromUri(output, True)\n"
            s+="\tfields=layer.pendingFields()\n"
            s+="\texpectednames=[" + ",".join(["'" + str(f.name()) + "'" for f in fields]) + "]\n"
            s+="\texpectedtypes=[" + ",".join(["'" + str(f.typeName()) +"'" for f in fields]) + "]\n"
            s+="\tnames=[str(f.name()) for f in fields]\n"
            s+="\ttypes=[str(f.typeName()) for f in fields]\n"
            s+="\tself.assertEqual(expectednames, names)\n"
            s+="\tself.assertEqual(expectedtypes, types)\n"
            features = QGisLayers.features(layer)
            numfeat = len(features)
            s+="\tfeatures=sextante.getfeatures(layer)\n"
            s+="\tself.assertEqual(" + str(numfeat) + ", len(features))\n"
            if numfeat > 0:
                feature = features.next()
                attrs = feature.attributes()
                s+="\tfeature=features.next()\n"
                s+="\tattrs=feature.attributes()\n"
                s+="\texpectedvalues=[" + ",".join(['"' + str(attr.toString()) + '"' for attr in attrs]) + "]\n"
                s+="\tvalues=[str(attr.toString()) for attr in attrs]\n"
                s+="\tself.assertEqual(expectedvalues, values)\n"

    dlg = ShowTestDialog(s)
    dlg.exec_()
开发者ID:jietaowang,项目名称:Quantum-GIS,代码行数:58,代码来源:TestTools.py


示例3: initGui

    def initGui(self):
        self.toolbox = SextanteToolbox(self.iface)
        self.toolbox.setVisible(False)
        Sextante.addAlgListListener(self.toolbox)

        self.menu = QMenu(self.iface.mainWindow())
        self.menu.setTitle(QCoreApplication.translate("SEXTANTE", "Analysis"))

        self.toolboxAction = QAction(
            QIcon(":/sextante/images/toolbox.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE toolbox"),
            self.iface.mainWindow(),
        )
        QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
        self.menu.addAction(self.toolboxAction)

        self.modelerAction = QAction(
            QIcon(":/sextante/images/model.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE modeler"),
            self.iface.mainWindow(),
        )
        QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
        self.menu.addAction(self.modelerAction)

        self.historyAction = QAction(
            QIcon(":/sextante/images/history.gif"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE history and log"),
            self.iface.mainWindow(),
        )
        QObject.connect(self.historyAction, SIGNAL("triggered()"), self.openHistory)
        self.menu.addAction(self.historyAction)

        self.configAction = QAction(
            QIcon(":/sextante/images/config.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE options and configuration"),
            self.iface.mainWindow(),
        )
        QObject.connect(self.configAction, SIGNAL("triggered()"), self.openConfig)
        self.menu.addAction(self.configAction)

        self.resultsAction = QAction(
            QIcon(":/sextante/images/results.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE results viewer"),
            self.iface.mainWindow(),
        )
        QObject.connect(self.resultsAction, SIGNAL("triggered()"), self.openResults)
        self.menu.addAction(self.resultsAction)

        self.helpAction = QAction(
            QIcon(":/sextante/images/help.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE help"),
            self.iface.mainWindow(),
        )
        QObject.connect(self.helpAction, SIGNAL("triggered()"), self.openHelp)
        self.menu.addAction(self.helpAction)

        menuBar = self.iface.mainWindow().menuBar()
        menuBar.insertMenu(menuBar.actions()[-1], self.menu)
开发者ID:geolab,项目名称:Quantum-GIS,代码行数:58,代码来源:SextantePlugin.py


示例4: fillTreeUsingProviders

    def fillTreeUsingProviders(self):
        self.algorithmTree.clear()
        text = unicode(self.searchBox.text())
        for providerName in Sextante.algs.keys():
            groups = {}
            provider = Sextante.algs[providerName]
            name = "ACTIVATE_" + providerName.upper().replace(" ", "_")
            if not SextanteConfig.getSetting(name):
                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()
                    + " ["
                    + str(len(provider))
                    + " geoalgorithms]",
                )
                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)
                providerItem.setExpanded(text != "")
                for groupItem in groups.values():
                    groupItem.setExpanded(text != "")
开发者ID:jetuk,项目名称:Quantum-GIS,代码行数:54,代码来源:SextanteToolbox.py


示例5: createTest

def createTest(item):            
    s = ""                
    tokens = item.entry.text[len("sextante.runalg("):-1].split(",")                
    cmdname = tokens[0][1:-1];
    methodname = "test_" + cmdname.replace(":","")
    s += "def " + methodname + "():\n"
    alg = Sextante.getAlgorithm(cmdname)
    execcommand = "sextante.runalg("
    i = 0
    for token in tokens:
        if i < alg.getVisibleParametersCount():
            execcommand+=token + ","
        else:
            execcommand+="None,"
        i+=1                
    s += "\toutputs=" + execcommand[:-1] + ")\n"
                
    i = -1 * len(alg.outputs)
    for out in alg.outputs:
        filename = tokens[i][1:-1]                    
        s+="\toutput=outputs['" + out.name + "']\n"
        if isinstance(out, (OutputNumber, OutputString)):
            s+="self.assertTrue(" + str(out) + ", output)\n"
        if isinstance(out, OutputRaster):                   
            dataset = gdal.Open(filename, GA_ReadOnly)
            array = dataset.ReadAsArray(1)
            s+="\tself.assertTrue(os.path.isfile(output))\n"
            s+="\tself.assertEqual(hashraster(output)," + str(hash(array)) + ")\n"
        if isinstance(out, OutputVector):
            layer = Sextante.getObject(filename)
            fields = layer.pendingFields()
            s+="\tlayer=sextante.getobject(output)\n"
            s+="\tfields=layer.pendingFields()\n"
            s+="\texpectednames=[" + ",".join([str(f.name()) for f in fields]) + "]\n"
            s+="\texpectedtypes=[" + ",".join([str(f.typeName()) for f in fields]) + "]\n"
            s+="\tnames=[str(f.name()) for f in fields]\n"
            s+="\ttypes=[str(f.typeName()) for f in fields]\n"
            s+="\tself.assertEqual(exceptednames, names)\n"
            s+="\tself.assertEqual(exceptedtypes, types)\n"
            features = QGisLayers.features(layer)
            numfeat = len(features)
            s+="\tfeatures=sextante.getfeatures(layer))\n"
            s+="\tself.assertEqual(" + str(numfeat) + ", len(features)\n"
            if numfeat > 0:
                feature = features.next()
                attrs = feature.attributes()
                s+="\tfeature=features.next()\n"
                s+="\tattrs=feature.attributes()\n"
                s+="\texpectedvalues=[" + ",".join([str(attr.toString()) for attr in attrs]) + "]\n"
                s+="\tvalues=[str(attr.toString()) for attr in attrs]\n"
                s+="\tself.assertEqual(exceptedtypes, types)\n"
    
    dlg = ShowTestDialog(s)
    dlg.exec_()
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:54,代码来源:TestTools.py


示例6: initGui

    def initGui(self):
        self.toolbox = SextanteToolbox(self.iface)
        self.toolbox.setVisible(False)
        Sextante.addAlgListListener(self.toolbox)

        self.menu = QMenu(self.iface.mainWindow())
        self.menu.setTitle("Analysis")

        icon = QIcon(os.path.dirname(__file__) + "/images/toolbox.png")
        self.toolboxAction = QAction(icon, \
            "&SEXTANTE Toolbox", self.iface.mainWindow())
        QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
        self.menu.addAction(self.toolboxAction)

        icon = QIcon(os.path.dirname(__file__) + "/images/model.png")
        self.modelerAction = QAction(icon, \
            "&SEXTANTE Modeler", self.iface.mainWindow())
        QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
        self.menu.addAction(self.modelerAction)

        icon = QIcon(os.path.dirname(__file__) + "/images/history.gif")
        self.historyAction = QAction(icon, \
            "&SEXTANTE History and log", self.iface.mainWindow())
        QObject.connect(self.historyAction, SIGNAL("triggered()"), self.openHistory)
        self.menu.addAction(self.historyAction)

        icon = QIcon(os.path.dirname(__file__) + "/images/config.png")
        self.configAction = QAction(icon, \
            "&SEXTANTE options and configuration", self.iface.mainWindow())
        QObject.connect(self.configAction, SIGNAL("triggered()"), self.openConfig)
        self.menu.addAction(self.configAction)

        icon = QIcon(os.path.dirname(__file__) + "/images/results.png")
        self.resultsAction = QAction(icon, \
            "&SEXTANTE results viewer", self.iface.mainWindow())
        QObject.connect(self.resultsAction, SIGNAL("triggered()"), self.openResults)
        self.menu.addAction(self.resultsAction)

        icon = QIcon(os.path.dirname(__file__) + "/images/help.png")
        self.helpAction = QAction(icon, \
            "&SEXTANTE help", self.iface.mainWindow())
        QObject.connect(self.helpAction, SIGNAL("triggered()"), self.openHelp)
        self.menu.addAction(self.helpAction)

        icon = QIcon(os.path.dirname(__file__) + "/images/info.png")
        self.aboutAction = QAction(icon, \
            "&About SEXTANTE", self.iface.mainWindow())
        QObject.connect(self.aboutAction, SIGNAL("triggered()"), self.openAbout)
        self.menu.addAction(self.aboutAction)

        menuBar = self.iface.mainWindow().menuBar()
        menuBar.insertMenu(menuBar.actions()[-1], self.menu)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:52,代码来源:SextantePlugin.py


示例7: initGui

    def initGui(self):
        self.toolbox = SextanteToolbox(self.iface)
        self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
        self.toolbox.hide()
        Sextante.addAlgListListener(self.toolbox)

        self.menu = QMenu(self.iface.mainWindow())
        self.menu.setTitle(QCoreApplication.translate("SEXTANTE", "Analysis"))

        self.toolboxAction = self.toolbox.toggleViewAction()
        self.toolboxAction.setIcon(QIcon(":/sextante/images/toolbox.png"))
        self.toolboxAction.setText(QCoreApplication.translate("SEXTANTE", "&SEXTANTE toolbox"))
        self.menu.addAction(self.toolboxAction)

        self.modelerAction = QAction(QIcon(":/sextante/images/model.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE modeler"),
            self.iface.mainWindow())
        self.modelerAction.triggered.connect(self.openModeler)
        self.menu.addAction(self.modelerAction)

        self.historyAction = QAction(QIcon(":/sextante/images/history.gif"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE history and log"),
            self.iface.mainWindow())
        self.historyAction.triggered.connect(self.openHistory)
        self.menu.addAction(self.historyAction)

        self.configAction = QAction(QIcon(":/sextante/images/config.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE options and configuration"),
            self.iface.mainWindow())
        self.configAction.triggered.connect(self.openConfig)
        self.menu.addAction(self.configAction)

        self.resultsAction = QAction(QIcon(":/sextante/images/results.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE results viewer"),
            self.iface.mainWindow())
        self.resultsAction.triggered.connect(self.openResults)
        self.menu.addAction(self.resultsAction)

        #=======================================================================
        # self.helpAction = QAction(QIcon(":/sextante/images/help.png"),
        #    QCoreApplication.translate("SEXTANTE", "&SEXTANTE help"),
        #    self.iface.mainWindow())
        # self.helpAction.triggered.connect(self.openHelp)
        # self.menu.addAction(self.helpAction)
        #=======================================================================

        menuBar = self.iface.mainWindow().menuBar()
        menuBar.insertMenu(menuBar.actions()[-1], self.menu)
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:48,代码来源:SextantePlugin.py


示例8: initGui

    def initGui(self):
        self.commander = None
        self.toolbox = SextanteToolbox(self.iface)
        self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
        self.toolbox.hide()
        Sextante.addAlgListListener(self.toolbox)

        self.menu = QMenu(self.iface.mainWindow())
        self.menu.setTitle(QCoreApplication.translate("SEXTANTE", "Analysis"))

        self.toolboxAction = self.toolbox.toggleViewAction()
        self.toolboxAction.setIcon(QIcon(":/sextante/images/toolbox.png"))
        self.toolboxAction.setText(QCoreApplication.translate("SEXTANTE", "&SEXTANTE toolbox"))
        self.menu.addAction(self.toolboxAction)

        self.modelerAction = QAction(QIcon(":/sextante/images/model.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE modeler"),
            self.iface.mainWindow())
        self.modelerAction.triggered.connect(self.openModeler)
        self.menu.addAction(self.modelerAction)

        self.historyAction = QAction(QIcon(":/sextante/images/history.gif"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE history and log"),
            self.iface.mainWindow())
        self.historyAction.triggered.connect(self.openHistory)
        self.menu.addAction(self.historyAction)

        self.configAction = QAction(QIcon(":/sextante/images/config.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE options and configuration"),
            self.iface.mainWindow())
        self.configAction.triggered.connect(self.openConfig)
        self.menu.addAction(self.configAction)

        self.resultsAction = QAction(QIcon(":/sextante/images/results.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE results viewer"),
            self.iface.mainWindow())
        self.resultsAction.triggered.connect(self.openResults)
        self.menu.addAction(self.resultsAction)

        menuBar = self.iface.mainWindow().menuBar()
        menuBar.insertMenu(self.iface.firstRightStandardMenu().menuAction(), self.menu)

        self.commanderAction = QAction(QIcon(":/sextante/images/toolbox.png"),
            QCoreApplication.translate("SEXTANTE", "&SEXTANTE commander"),
            self.iface.mainWindow())
        self.commanderAction.triggered.connect(self.openCommander)
        self.menu.addAction(self.commanderAction)
        self.iface.registerMainWindowAction(self.commanderAction, "Ctrl+Alt+M")
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:48,代码来源:SextantePlugin.py


示例9: processAlgorithm

	def processAlgorithm(self, progress):
		# Include must be done here to avoid cyclic import
		from sextante.core.Sextante import Sextante
		qgis = Sextante.getInterface()

		layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
		layername = layer.name()
		savename = self.getOutputValue(self.SAVENAME)

		index = self.getParameterValue(self.NEWTYPE)

		splitnodes = 0
		if index == 0:
			newtype = QGis.WKBPoint
		elif index == 1:
			newtype = QGis.WKBPoint
			splitnodes = 1
		elif index == 2:
			newtype = QGis.WKBLineString
		elif index == 3:
			newtype = QGis.WKBMultiLineString
		elif index == 4:
			newtype = QGis.WKBPolygon
		else:
			newtype = QGis.WKBPoint

		message = mmqgisx_geometry_convert(qgis, layername, newtype, splitnodes, savename, False)

		if message:
			raise GeoAlgorithmExecutionException(message)
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:30,代码来源:MMQGISXAlgorithmProvider.py


示例10: processAlgorithm

    def processAlgorithm(self, progress):
        # Include must be done here to avoid cyclic import
        from sextante.core.Sextante import Sextante

        qgis = Sextante.getInterface()

        table = QGisLayers.getObjectFromUri(self.getParameterValue(self.CSVNAME))
        csvname = table.name()

        params = [
            self.getParameterValue(self.ADDRESS),
            self.getParameterValue(self.CITY),
            self.getParameterValue(self.STATE),
            self.getParameterValue(self.COUNTRY),
        ]

        keys = []
        for param in params:
            if not (param in keys):
                keys.append(param)

        shapefilename = self.getOutputValue(self.SHAPEFILENAME)
        notfoundfile = self.getOutputValue(self.NOTFOUNDFILE)

        message = mmqgisx_geocode_google(qgis, csvname, shapefilename, notfoundfile, keys, False)

        if message:
            raise GeoAlgorithmExecutionException(message)
开发者ID:psibi,项目名称:Quantum-GIS,代码行数:28,代码来源:MMQGISXAlgorithms.py


示例11: alghelp

def alghelp(name):
    alg = Sextante.getAlgorithm(name)
    if alg != None:
        print(str(alg))
        algoptions(name)
    else:
        print "Algorithm not found"
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:7,代码来源:general.py


示例12: processAlgorithm

    def processAlgorithm(self, progress):
        '''Here is where the processing itself takes place'''

        #the first thing to do is retrieve the values of the parameters
        #entered by the user
        inputFilename = self.getParameterValue(self.INPUT_LAYER)
        output = self.getOutputValue(self.OUTPUT_LAYER)

        #input layers values are always a string with its location.
        #That string can be converted into a QGIS object (a QgsVectorLayer in this case))
        #using the Sextante.getObject() method
        vectorLayer = Sextante.getObject(inputFilename)

        #And now we can process

        #First we create the output layer.
        #The output value entered by the user is a string containing a filename,
        #so we can use it directly
        settings = QSettings()
        systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
        provider = vectorLayer.dataProvider()
        writer = QgsVectorFileWriter( output, systemEncoding, provider.fields(), provider.geometryType(), provider.crs() )

        #Now we take the selected features and add them to the output layer
        selection = vectorLayer.selectedFeatures()
        for feat in selection:
            writer.addFeature(feat)
        del writer
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:28,代码来源:ExampleAlgorithm.py


示例13: fillTree

    def fillTree(self):
        useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
        if useCategories:
            self.fillTreeUsingCategories()
        else:
            self.fillTreeUsingProviders()

        self.algorithmTree.sortItems(0, Qt.AscendingOrder)

        showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
        if showRecent:
            recent = SextanteLog.getRecentAlgorithms()
            if len(recent) != 0:
                found = False
                recentItem = QTreeWidgetItem()
                recentItem.setText(0, self.tr("Recently used algorithms"))
                for algname in recent:
                    alg = Sextante.getAlgorithm(algname)
                    if alg is not None:
                        algItem = TreeAlgorithmItem(alg)
                        recentItem.addChild(algItem)
                        found = True
                if found:
                    self.algorithmTree.insertTopLevelItem(0, recentItem)
                    recentItem.setExpanded(True)

            self.algorithmTree.setWordWrap(True)
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:27,代码来源:SextanteToolbox.py


示例14: addRecentAlgorithms

    def addRecentAlgorithms(self, updating):
        showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
        if showRecent:
            recent = SextanteLog.getRecentAlgorithms()
            if len(recent) != 0:
                found = False
                if updating:
                    recentItem = self.algorithmTree.topLevelItem(0)
                    treeWidget = recentItem.treeWidget()
                    treeWidget.takeTopLevelItem(treeWidget.indexOfTopLevelItem(recentItem))
                    #self.algorithmTree.removeItemWidget(first, 0)

                recentItem = QTreeWidgetItem()
                recentItem.setText(0, self.tr("Recently used algorithms"))
                for algname in recent:
                    alg = Sextante.getAlgorithm(algname)
                    if alg is not None:
                        algItem = TreeAlgorithmItem(alg)
                        recentItem.addChild(algItem)
                        found = True
                if found:
                    self.algorithmTree.insertTopLevelItem(0, recentItem)
                    recentItem.setExpanded(True)

            self.algorithmTree.setWordWrap(True)
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:25,代码来源:SextanteToolbox.py


示例15: processAlgorithm

	def processAlgorithm(self, progress):
		# Include must be done here to avoid cyclic import
		from sextante.core.Sextante import Sextante
		qgis = Sextante.getInterface()

		layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
		layername = layer.name()

		node_filename = self.getOutputValue(self.NODEFILENAME)
		attribute_filename = self.getOutputValue(self.ATTRIBUTEFILENAME)
		print "Layer: " + str(layername)
		print "Nodes: " + str(node_filename)
		print "Attributes: " + str(attribute_filename)

		if self.getParameterValue(self.FIELDDELIMITER) == 1:
			field_delimiter = "|"
		elif self.getParameterValue(self.FIELDDELIMITER) == 2:
			field_delimiter = " "
		else:
			field_delimiter = ","

		if self.getParameterValue(self.LINETERMINATOR) == 1:
			line_terminator = "\n"
		else:
			line_terminator = "\r\n"

		message = mmqgisx_geometry_export_to_csv(qgis, layername, node_filename, attribute_filename,
			field_delimiter, line_terminator)

		if message:
			raise GeoAlgorithmExecutionException(message)
开发者ID:pka,项目名称:qgisenterprise-sextante-plugin,代码行数:31,代码来源:MMQGISXAlgorithms.py


示例16: executeAlgorithm

 def executeAlgorithm(self):
     item = self.algorithmTree.currentItem()
     if isinstance(item, TreeAlgorithmItem):
         alg = Sextante.getAlgorithm(item.alg.commandLineName())
         message = alg.checkBeforeOpeningParametersDialog()
         if message:
             dlg = MissingDependencyDialog(message)
             dlg.exec_()
             #QMessageBox.warning(self, self.tr("Warning"), message)
             return
         alg = alg.getCopy()
         dlg = alg.getCustomParametersDialog()
         if not dlg:
             dlg = ParametersDialog(alg)
         canvas = QGisLayers.iface.mapCanvas()
         prevMapTool = canvas.mapTool()
         dlg.show()
         dlg.exec_()
         if canvas.mapTool()!=prevMapTool:
             try:
                 canvas.mapTool().reset()
             except:
                 pass
             canvas.setMapTool(prevMapTool)
         if dlg.executed:
             showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
             if showRecent:
                 self.addRecentAlgorithms(True)
     if isinstance(item, TreeActionItem):
         action = item.action
         action.setData(self)
         action.execute()
开发者ID:Hardysong,项目名称:Quantum-GIS,代码行数:32,代码来源:SextanteToolbox.py


示例17: unload

  def unload(self):
     if hasattr(self.iface,  "addPluginToWebMenu"):
         self.iface.removePluginWebMenu("QgsWPSClient", self.action)
         self.iface.removePluginWebMenu("QgsWPSClient", self.actionAbout)
     else:
         self.iface.removePluginToMenu("QgsWPSClient", self.action)      
         self.iface.removePluginToMenu("QgsWPSClient", self.actionAbout)
         
     self.iface.removeToolBarIcon(self.action)
    
     if self.myDockWidget:
         self.myDockWidget.close()
        
     self.myDockWidget = None

     if self.provider:
        Sextante.removeProvider(self.provider)
开发者ID:maelocrowd,项目名称:QGis_plugin,代码行数:17,代码来源:qgswps.py


示例18: runalg_none

 def runalg_none(self):
     result = Sextante.runalg(self.alg, *self.args)
     print bcolors.ENDC
     self.assertIsNotNone(result, self.msg)
     if not result:
         return
     for p in result.values():
         if isinstance(p, str):
             self.assertTrue(os.path.exists(p), "Output %s exists" % p)
开发者ID:carsonfarmer,项目名称:Quantum-GIS,代码行数:9,代码来源:test.py


示例19: setSessionProjectionFromProject

 def setSessionProjectionFromProject(self, commands):
     if not GrassUtils.projectionSet:
         from sextante.core.Sextante import Sextante
         qgis = Sextante.getInterface()
         proj4 = qgis.mapCanvas().mapRenderer().destinationCrs().toProj4()
         command = "g.proj"
         command +=" -c"
         command +=" proj4=\""+proj4+"\""
         commands.append(command)
         GrassUtils.projectionSet = True
开发者ID:tomyun,项目名称:Quantum-GIS,代码行数:10,代码来源:GrassAlgorithm.py


示例20: processAlgorithm

    def processAlgorithm(self, progress):
        # get the lib
        liblwgeom = self.getLwgeomLibrary()

        # retrieve the values of the parameters entered by the user
        inputFilename = self.getParameterValue(self.INPUT_LAYER)
        output = self.getOutputValue(self.OUTPUT_LAYER)

        # input layers vales are always a string with its location.
        # That string can be converted into a QGIS object (a QgsVectorLayer in this case))
        # using the Sextante.getObject() method
        inputLayer = Sextante.getObject(inputFilename)

        # create the output layer
        provider = inputLayer.dataProvider()
        encoding = provider.encoding()
        geomType = self.inputToOutputGeomType(inputLayer)
        writer = QgsVectorFileWriter( output, encoding, provider.fields(), geomType, provider.crs() )

        # Now we take the features and add them to the output layer, 
        # first check for selected features
        selection = inputLayer.selectedFeatures()
        if len(selection) > 0:
            count = len(selection)
            idx = 0

            for feat in selection:
                # run lwgeom algorithm on the feature geometry
                if not self.runLwgeom( feat.geometry(), lib=liblwgeom ):
                    SextanteLog.addToLog( SextanteLog.LOG_ERROR, u"FAILURE: previous failure info: layer %s, feature #%s" % (inputLayer.source(), feat.id()) )
                writer.addFeature(feat)

                progress.setPercentage( idx*100/count )
                idx += 1

        else:
            count = inputLayer.featureCount()
            idx = 0

            # no features selected on the layer, process all the features
            inputLayer.select( inputLayer.pendingAllAttributesList(), QgsRectangle(), True )
            feat = QgsFeature()
            while inputLayer.nextFeature( feat ):
                # run lwgeom algorithm on the feature geometry
                if not self.runLwgeom( feat.geometry(), lib=liblwgeom ):
                    SextanteLog.addToLog( SextanteLog.LOG_ERROR, u"FAILURE: previous failure info: layer %s, feature #%s" % (inputLayer.source(), feat.id()) )
                writer.addFeature(feat)

                progress.setPercentage( idx*100/count )
                idx += 1

        del writer
        progress.setPercentage( 100 )
开发者ID:SIGISLV,项目名称:processinglwgeomprovider,代码行数:53,代码来源:LwgeomAlgorithm.py



注:本文中的sextante.core.Sextante.Sextante类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python SextanteConfig.SextanteConfig类代码示例发布时间:2022-05-27
下一篇:
Python QGisLayers.QGisLayers类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap