210 Commits

Author SHA1 Message Date
Nyall Dawson
b5197c8c53 Port drop geometries to c++ 2017-10-13 08:29:37 +10:00
Nyall Dawson
2951afa324 Port boundary algorithm to c++
Also allow feature based algorithms to customise their appectable
input layers types and set suitable filters for all applicable
algorithms
2017-10-13 08:28:34 +10:00
Alexander Bruy
2104b273af [processing][API]introduce QgsProcessingOutputFile output and fix gdal2xyz test 2017-10-11 17:06:11 +03:00
Denis Rouzaud
6e14854f90 [sipify] remove redundant private sections 2017-10-09 09:51:40 +02:00
Nyall Dawson
b27382d011 [processing] Fix history doesn't correctly escape values
Fixes #17229
2017-10-03 19:01:13 +10:00
Nyall Dawson
01d34ede9d Sip sync 2017-09-25 17:12:03 +10:00
Nyall Dawson
e1eef7ed19 Allow use of QgsPointXY/QgsReferencedPointXY for point parameter values 2017-09-24 12:09:38 +10:00
Nyall Dawson
57b76920d6 Expand docs 2017-09-22 15:22:01 +10:00
Nyall Dawson
c41dca937c Port processing combineFields to c++ 2017-09-22 15:19:32 +10:00
Nyall Dawson
6afe25ef0f [processing] Proper progress reports during model execution
Instead of showing the progress reports for each child algorithm
individually, which leads to repeated 0->100% progress for every
step of a model, we proxy the progress reports and account for the
overall progress through a model as well. This means that
the progress accounts for both the progress within the current
model step AND the total number of steps left to execute.
2017-09-22 10:32:17 +10:00
Mathieu Pellerin
09195fb567 [processing] implement source flag for feature based algorithms (#5208) 2017-09-18 13:33:20 +07:00
Nyall Dawson
9b112284c7 Add method to recover extent parameter CRS 2017-09-15 14:09:27 +10:00
Nyall Dawson
cfdc3c71e7 Use geometry of reproject extent parameters for more accurate clipping 2017-09-15 08:35:42 +10:00
Nyall Dawson
ae8bc04b6c Allow use of Qgs(Referenced)Rectangle for processing extent parameter values
And add a new target CRS argument to parameterAsExtent. If set, and
the source CRS of the rectangle parameter can be determined, then
the returned value will be the rectangle automatically reprojected
to the desired target CRS.
2017-09-15 08:33:45 +10:00
Nyall Dawson
cb70aad7a3 Fix restricting model algorithm input types to valid types for alg (refs #17030) 2017-08-23 17:34:08 +10:00
Nyall Dawson
ebda2fd212 Rename some enum values for clarity 2017-08-19 02:46:22 +10:00
Nyall Dawson
7879c0a20b Fix processing rendering styles for output dialog, functionality 2017-08-19 00:47:21 +10:00
Nyall Dawson
37b899fb99 Add a pure virtual clone method to processing parameter definitions
And use it when we need to clone parameters (instead of more fragile
conversion to and from variants)

This fixes model loading which use algorithms which create python
subclasses of parameter definitions
2017-08-18 01:22:07 +10:00
arnaud.morvan@camptocamp.com
b3a9e46cfe [processing] Port refactor fields to new API 2017-08-14 13:48:50 +02:00
Alexander Bruy
9fe326dee2 [processing] more consistent naming for class members, setters and
getters
2017-08-04 13:21:26 +03:00
Alexander Bruy
49bfe69823 [processing] add parameter representing raster band 2017-08-04 11:27:35 +03:00
Nyall Dawson
f7b25a17b1 Allow setting layer type filter for QgsProcessingParameterVectorLayer
Turns out this is required for some algorithms
2017-07-27 14:30:04 +10:00
Nyall Dawson
383422f069 Fix "wrapped object has been deleted" errors in Processing
Ownership of Python subclass algorithm instances was getting
mangled due to passing through multiple functions with /Factory/
annotations.

As per Phil Thomson's advice on
https://www.riverbankcomputing.com/pipermail/pyqt/2017-July/039450.html:
"
/Factory/ is used when the instance returned is guaranteed to be
new to Python. In this case it isn't because it has already been
seen when being returned by createInstance(). (However for a different
sub-class implemented in C++ then it would be the first time it was seen
by Python so the /Factory/ on create() would be correct.)

You might try using /TransferBack/ on create() instead - that might be
the best compromise.
"

Changing to /TransferBack/ indeed fixes the error for me.
2017-07-26 07:03:16 +10:00
Nyall Dawson
11cfc78a24 Skip invalid returned features 2017-07-18 22:13:50 +10:00
Nyall Dawson
29855b3942 Change signature of processFeature so that features are no longer modified in place 2017-07-18 19:56:42 +10:00
Nyall Dawson
c2cad99d6b Add note about throwing QgsProcessingException to cancel algorithm execution 2017-07-18 19:44:33 +10:00
Nyall Dawson
d926789d3b Improve dox 2017-07-18 19:41:33 +10:00
Nyall Dawson
7e3c435dd6 Port some existing algorithms to QgsProcessingFeatureBasedAlgorithm 2017-07-18 19:41:33 +10:00
Nyall Dawson
1a41624370 Add QgsProcessingFeatureBasedAlgorithm subclass
An abstract QgsProcessingAlgorithm base class for processing algorithms
which operate "feature-by-feature".

Feature based algorithms are algorithms which operate on individual
features in isolation. These are algorithms where one feature is
output for each input feature, and the output feature result
for each input feature is not dependent on any other features
present in the source.

For instance, algorithms like "centroids" and "buffers" are feature
based algorithms since the centroid or buffer of a feature is
calculated for each feature in isolation. An algorithm like "dissolve"
is NOT suitable for a feature based algorithm as the dissolved output
depends on multiple input features and these features cannot be
processed in isolation.

Using QgsProcessingFeatureBasedAlgorithm as the base class for feature
based algorithms allows shortcutting much of the common algorithm code
for handling iterating over sources and pushing features to output sinks.
It also allows the algorithm execution to be optimised in future
(for instance allowing automatic multi-thread processing of the
algorithm, or use of the algorithm in "chains", avoiding the need
for temporary outputs in multi-step models).
2017-07-18 19:41:33 +10:00
Nyall Dawson
1342f4d9ac Add API to set optional destination parameters as not created by default
This allows optional outputs (such as null geometry features detected
by the Remove Null Geometries algorithm) to be skipped by default
when desirable.
2017-07-16 18:19:24 +10:00
Nyall Dawson
b7ae44fb30 Move method to evaluate a variant to a feature source to QgsProcessingUtils 2017-07-13 20:51:47 +10:00
Nyall Dawson
eb0c3015f9 Push minimumValues/maximumValues up to QgsFeatureSource base class
Allows these methods to be called on feature sources
2017-07-13 20:07:33 +10:00
Nyall Dawson
058271b0c1 Auto create corresponding outputs when adding destination style
parameters to an algorithm

QgsProcessingAlgorithm::addParameter() has a new createOuput
argument (true by default).

If the createOutput argument is true, then a corresponding
output definition will also be created (and added to the
algorithm) where appropriate. E.g. when adding a
QgsProcessingParameterVectorDestination and createOutput is
true, then a QgsProcessingOutputVectorLayer output will be
created and added to the algorithm. There is no need to call
addOutput() to manually add a corresponding output for this
vector. If createOutput is false then this automatic output
creation will not occur.

This should simplify declaration of outputs for algorithms
as it avoids the need to manually declare these corresponding
outputs.
2017-07-12 07:18:53 +10:00
Nyall Dawson
2b8e06719e Add sip subclass code for QgsProcessingAlgorithm 2017-07-10 17:09:42 +10:00
Nyall Dawson
326d6f5fc7 Allow child algorithm configuration to be stored and handled by models 2017-07-10 17:02:23 +10:00
Nyall Dawson
9e8a114553 Allow specifying algorithm configuration when calling create 2017-07-10 16:41:35 +10:00
Nyall Dawson
1e13d733c2 Move declaration of algorithm parameters/outputs to a new virtual
initAlgorithm() method

This allows 2 benefits:
- algorithms can be subclassed and have subclasses add additional
parameters/outputs to the algorithm. With the previous approach
of declaring parameters/outputs in the constructor, it's not
possible to call virtual methods to add additional parameters/
outputs (since you can't call virtual methods from a constructor).

- initAlgorithm takes a variant map argument, allowing the algorithm
to dynamically adjust its declared parameters and outputs according
to this configuration map. This potentially allows model algorithms which
can be configured to have variable numbers of parameters and
outputs at run time. E.g. a "router" algorithm which directs
features to one of any number of output sinks depending on some
user configured criteria.
2017-07-10 16:31:14 +10:00
Nyall Dawson
fc221a6ebe Add sip VirtualCatcherCode to avoid algorithm copies being
destroyed by the python garbage collector

The code generated with the /Factory/ annotation was not sufficient
to correctly transfer the ownership of objects created in Python
back to c++ (despite mailing list messages which hint that it
is).

Anyway, this awful abomination works. Let's all move on to more
useful ways to spend our time...
2017-07-10 15:51:02 +10:00
Nyall Dawson
03275bbace Split QgsProcessingAlgorithm::create into non virtual-create
and pure virtual createInstance

Allows us to add logic which always need applying within
create(), leaving createInstance() free to just return a
raw new instance of the class
2017-07-10 10:07:32 +10:00
Nyall Dawson
7753ba11f7 Model child algorithms store a copy of the algorithm itself
Instead of always retrieving it from the registry
2017-07-09 17:17:29 +10:00
Nyall Dawson
cd6e7d78cf Add method to processing registry to create a new instance of an algorithm directly 2017-07-09 17:14:45 +10:00
Nyall Dawson
fedf88ea3d Remove redundant sip file 2017-07-08 20:53:02 +10:00
Nyall Dawson
f49b603443 Split QgsProcessingModelAlgorithm into separate components
The cpp/h file was getting too large, so split off the individual
subcomponents into their own h/cpp files to keep code
maintainable.
2017-07-08 20:49:17 +10:00
Nyall Dawson
9d04f87249 Rename "output" style parameters for clarity
The previous naming was too easily confused with processing outputs.
Rename them to QgsProcessingParameterFileDestination, etc... to
make it clearer what they are used for.
2017-07-08 20:49:17 +10:00
Nyall Dawson
f82b41e001 Move an enum to new QgsProcessing class 2017-07-08 20:49:17 +10:00
Nyall Dawson
febf0a0e6e Rename method to more generic name - it's usable by vector layer outputs too 2017-07-08 20:49:17 +10:00
Nyall Dawson
d443bb3cbe Expose compatible vector layer parameter evaluation to QgsProcessingAlgorithm 2017-07-08 20:49:17 +10:00
Nyall Dawson
9e184feaed Add method to evaluate parameters to compatible vector layers
of a specified type
2017-07-08 20:49:17 +10:00
Nyall Dawson
ac51ae106c Add unit tests 2017-07-07 11:36:41 +10:00
Nyall Dawson
3ea70696f0 Add descriptions for model algorithm variables 2017-07-07 11:35:31 +10:00