drop old processing provider example which is not compatible QGIS 3

This commit is contained in:
Etienne Trimaille 2019-03-06 10:11:13 -04:00 committed by Nyall Dawson
parent 7aa7248b97
commit fa843f8705
7 changed files with 0 additions and 334 deletions

View File

@ -6,6 +6,5 @@ ADD_SUBDIRECTORY(grass7)
ADD_SUBDIRECTORY(otb)
ADD_SUBDIRECTORY(saga)
ADD_SUBDIRECTORY(qgis)
ADD_SUBDIRECTORY(exampleprovider)
PLUGIN_INSTALL(processing algs ${PY_FILES})

View File

@ -1,4 +0,0 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB OTHER_FILES *.txt)
PLUGIN_INSTALL(processing ./algs/exampleprovider ${PY_FILES} ${OTHER_FILES})

View File

@ -1,125 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
__init__.py
---------------------
Date : July 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'July 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from qgis.core import QgsVectorFileWriter, QgsSettings, QgsProcessingUtils
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
from processing.tools import dataobjects
class ExampleAlgorithm(GeoAlgorithm):
"""This is an example algorithm that takes a vector layer and
creates a new one just with just those features of the input
layer that are selected.
It is meant to be used as an example of how to create your own
algorithms and explain methods and variables used to do it. An
algorithm like this will be available in all elements, and there
is not need for additional work.
All Processing algorithms should extend the GeoAlgorithm class.
"""
# Constants used to refer to parameters and outputs. They will be
# used when calling the algorithm from another algorithm, or when
# calling from the QGIS console.
OUTPUT_LAYER = 'OUTPUT_LAYER'
INPUT_LAYER = 'INPUT_LAYER'
def __init__(self):
super().__init__()
"""Here we define the inputs and output of the algorithm, along
with some other properties.
"""
# We add the input vector layer. It can have any kind of geometry
# It is a mandatory (not optional) one, hence the False argument
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [dataobjects.TYPE_VECTOR_ANY], False))
# We add a vector layer as output
self.addOutput(OutputVector(self.OUTPUT_LAYER,
self.tr('Output layer with selected features')))
def name(self):
# Unique (non-user visible) name of algorithm
return 'create_copy_of_layer'
def displayName(self):
# The name that the user will see in the toolbox
return self.tr('Create copy of layer')
def group(self):
return self.tr('Algorithms for vector layers')
def processAlgorithm(self, parameters, context, feedback):
"""Here is where the processing itself takes place.
:param parameters:
:param context:
"""
# 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 vales are always a string with its location.
# That string can be converted into a QGIS layer (a
# QgsVectorLayer in this case) using the
# QgsProcessingUtils.mapLayerFromString() method.
vectorLayer = QgsProcessingUtils.mapLayerFromString(inputFilename, context)
# 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 = QgsSettings()
systemEncoding = settings.value('/UI/encoding', 'System')
writer = QgsVectorFileWriter(output,
systemEncoding,
vectorLayer.fields(),
vectorLayer.wkbType(),
vectorLayer.crs())
# Now we take the features from input layer and add them to the
# output. Method features() returns an iterator, considering the
# selection that might exist in layer and the configuration that
# indicates should algorithm use only selected features or all
# of them
features = QgsProcessingUtils.getFeatures(vectorLayer, context)
for f in features:
writer.addFeature(f)
# There is nothing more to do here. We do not have to open the
# layer that we have created. The framework will take care of
# that, or will handle it if this algorithm is executed within
# a complex model

View File

@ -1,103 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
__init__.py
---------------------
Date : July 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'July 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from qgis.core import QgsProcessingProvider
from processing.core.ProcessingConfig import Setting, ProcessingConfig
from exampleprovider.ExampleAlgorithm import ExampleAlgorithm
class ExampleAlgorithmProvider(QgsProcessingProvider):
MY_DUMMY_SETTING = 'MY_DUMMY_SETTING'
def __init__(self):
super().__init__()
def load(self):
"""In this method we add settings needed to configure our
provider.
"""
ProcessingConfig.settingIcons[self.name()] = self.icon()
# Deactivate provider by default
ProcessingConfig.addSetting(Setting(self.name(), 'ACTIVATE_EXAMPLE',
'Activate', False))
ProcessingConfig.addSetting(Setting('Example algorithms',
ExampleAlgorithmProvider.MY_DUMMY_SETTING,
'Example setting', 'Default value'))
ProcessingConfig.readSettings()
self.refreshAlgorithms()
return True
def unload(self):
"""Setting should be removed here, so they do not appear anymore
when the plugin is unloaded.
"""
ProcessingConfig.removeSetting('ACTIVATE_EXAMPLE')
ProcessingConfig.removeSetting(
ExampleAlgorithmProvider.MY_DUMMY_SETTING)
def isActive(self):
"""Return True if the provider is activated and ready to run algorithms"""
return ProcessingConfig.getSetting('ACTIVATE_EXAMPLE')
def setActive(self, active):
ProcessingConfig.setSettingValue('ACTIVATE_EXAMPLE', active)
def id(self):
"""This is the name that will appear on the toolbox group.
It is also used to create the command line name of all the
algorithms from this provider.
"""
return 'example'
def name(self):
"""This is the localised full name.
"""
return 'Example algorithms'
def icon(self):
"""We return the default icon.
"""
return QgsProcessingProvider.icon(self)
def loadAlgorithms(self):
"""Here we fill the list of algorithms in self.algs.
This method is called whenever the list of algorithms should
be updated. If the list of algorithms can change (for instance,
if it contains algorithms from user-defined scripts and a new
script might have been added), you should create the list again
here.
In this case, since the list is always the same, we assign from
the pre-made list. This assignment has to be done in this method
even if the list does not change, since the self.algs list is
cleared before calling this method.
"""
for alg in [ExampleAlgorithm()]:
self.addAlgorithm(alg)

View File

@ -1,51 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
__init__.py
---------------------
Date : July 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'July 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
import sys
import inspect
from qgis.core import QgsApplication
from processing.core.Processing import Processing
from exampleprovider.ExampleAlgorithmProvider import ExampleAlgorithmProvider
cmd_folder = os.path.split(inspect.getfile(inspect.currentframe()))[0]
if cmd_folder not in sys.path:
sys.path.insert(0, cmd_folder)
class ProcessingExampleProviderPlugin:
def __init__(self):
self.provider = ExampleAlgorithmProvider()
def initGui(self):
QgsApplication.processingRegistry().addProvider(self.provider)
def unload(self):
QgsApplication.processingRegistry().removeProvider(self.provider)

View File

@ -1,32 +0,0 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
__init__.py
---------------------
Date : July 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Victor Olaya'
__date__ = 'July 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
from exampleprovider.ProcessingExampleProviderPlugin import ProcessingExampleProviderPlugin
def classFactory(iface):
return ProcessingExampleProviderPlugin()

View File

@ -1,18 +0,0 @@
[general]
name=Processing Example Provider
description=An example plugin that adds algorithms to Processing. Mainly created to guide developers in the process of creating plugins that add new capabilities to Processing
category=Analysis
version=2.0
qgisMinimumVersion=2.0
author=Victor Olaya
email=volayaf@gmail.com
tags=analysis,processing
homepage=
tracker=
repository=
experimental=False
deprecated=False