Advertisement
Guest User

Untitled

a guest
May 29th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. from PyQt5.QtCore import QCoreApplication
  4. from qgis.core import (QgsProcessing,
  5.                        QgsFeatureSink,
  6.                        QgsProcessingException,
  7.                        QgsProcessingAlgorithm,
  8.                        QgsProcessingParameterFeatureSource,
  9.                        QgsProcessingParameterFolderDestination)
  10. import processing
  11.  
  12.  
  13. class ExampleProcessingAlgorithm(QgsProcessingAlgorithm):
  14.  
  15.     INPUT = 'INPUT'
  16.     OUTPUT = 'OUTPUT'
  17.  
  18.     def tr(self, string):
  19.         return QCoreApplication.translate('Processing', string)
  20.  
  21.     def createInstance(self):
  22.         return ExampleProcessingAlgorithm()
  23.  
  24.     def name(self):
  25.         return 'myscript'
  26.  
  27.     def displayName(self):
  28.         return self.tr('My Script')
  29.  
  30.     def group(self):
  31.         return self.tr('Example scripts')
  32.  
  33.     def groupId(self):
  34.         return 'examplescripts'
  35.  
  36.     def initAlgorithm(self, config=None):
  37.  
  38.         self.addParameter(
  39.             QgsProcessingParameterFeatureSource(
  40.                 self.INPUT,
  41.                 self.tr('Input layer'),
  42.                 [QgsProcessing.TypeVectorAnyGeometry]
  43.             )
  44.         )
  45.  
  46.         self.addParameter(
  47.             QgsProcessingParameterFolderDestination(
  48.                 self.OUTPUT,
  49.                 self.tr('Output layer')
  50.             )
  51.         )
  52.  
  53.     def processAlgorithm(self, parameters, context, feedback):
  54.  
  55.         source = self.parameterAsSource(
  56.             parameters,
  57.             self.INPUT,
  58.             context
  59.         )
  60.  
  61.         output = self.parameterAsString(
  62.             parameters,
  63.             self.OUTPUT,
  64.             context
  65.         )
  66.  
  67.         feedback.pushDebugInfo(output)
  68.  
  69.  
  70.         return {self.OUTPUT: output}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement