410 Commits

Author SHA1 Message Date
Alexander Bruy
56208540f9 [processing] remove GeoAlgorithmExecutionException 2017-07-13 09:02:24 +03: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
82ef7d2a89 Create specific expression context scope for child algorithms
Contains variables for model parameters, algorithm results for
other child algorithms which are not dependent on the
algorithm.

Allows removal of final pieces of ModelerAlgorithm code
2017-07-07 11:35:31 +10:00
Nyall Dawson
55ce31b371 When calling procesing.run(), map layer results are automatically
converted to QgsMapLayer objects with the ownership transferred
to the Python caller

This should make it super-easy for PyQGIS scripts to run processing
algorithms and immediately utilise the results, even if they
are memory layers. They call processing.run(), and get a dict of
results back which includes those layers ready for adding to the
current project or doing some other processing or operations
with, and if they don't transfer to ownership off then these
layers will be correctly garbaged collected by Python.
2017-07-07 09:28:20 +10:00
Denis Rouzaud
5b8e2c2f27 remove QgsVectorLayer::hasGeometryType in favor of QgsMapLayer::isSpatial 2017-07-05 10:18:32 +02:00
Nyall Dawson
f98bcb2b81 Update processing.run() for new API 2017-06-27 13:18:22 +10:00
Nyall Dawson
4e93f8d038 Don't set override cursor in processing.run
Callers may not want this, so leave it up to them to set
an override caller if desired
2017-06-27 11:24:59 +10:00
Nyall Dawson
3286ebb470 Explicit parameters, feedback, context arguments for processing.run 2017-06-27 11:24:33 +10:00
Nyall Dawson
2a1cdead51 processing.run requires a dictionary for parameters 2017-06-27 11:19:29 +10:00
Nyall Dawson
449d8f8c0b Restore script algorithm provider 2017-06-27 10:50:07 +10:00
Nyall Dawson
3bf9ea3682 Restore ability to run script algorithms 2017-06-27 08:33:13 +10:00
Nyall Dawson
df329bceab Start restoring creation of outputs from string 2017-06-27 08:33:13 +10:00
Nyall Dawson
d16f117b6c Port conversion to/from script code to c++ 2017-06-27 08:33:13 +10:00
Nyall Dawson
178a415c9f Port parameter conversion to script code to c++ 2017-06-27 08:33:13 +10:00
Nyall Dawson
bb73596406 Load other providers before model provider 2017-06-24 13:49:10 +10:00
Nyall Dawson
9c47e1b148 Fix errors when edit model help 2017-06-24 07:35:56 +10:00
Nyall Dawson
81855a715b Use FastInsert when adding features from processing 2017-06-23 14:34:38 +10:00
Nyall Dawson
4ea85362f4 Transform errors encountered while iterating features in
processing are non-fatal. We report them to users, and treat the
feature as having no geometry, but don't stop execution.
2017-06-23 12:08:54 +10:00
Nyall Dawson
98617c90bd Report errors when executing algs within dialogs 2017-06-23 12:08:54 +10:00
Nyall Dawson
93b7c2809e Report success or failure after running algs
And auto catch python exceptions and report failure of model
2017-06-23 12:08:54 +10:00
Nyall Dawson
a87ca09e34 Move some temp file/folder utils to c++ 2017-06-22 06:48:25 +10:00
Nyall Dawson
be45c2fdbb Catch errors while running algs 2017-06-13 10:26:35 +10:00
Nyall Dawson
63611b1d8f Port script code functions to c++ classes
Restore logging executed algorithms
2017-06-12 15:59:56 +10:00
Nyall Dawson
2d2c229332 Port checkInputCRS to c++, and allow algorithms to flag when they
require all input layers to be in the same CRS

The default behaviour is to assume that algorithms are well behaved
and can handle multi-CRS inputs, but algs have the option to
flag that they do not allow this and require the input CRS check.

Those algs should document that they require all inputs to have
matching CRS - processing 3.0 behaviour is to assume that algs
can handle this.
2017-06-12 07:26:02 +10:00
Nyall Dawson
ea18e8e9db Resurrect grid polygon algorithm 2017-06-12 07:26:02 +10:00
Alexander Bruy
d859399ce5 [processing] use QGIS user manual as help source for all algorithms by
default.

NOTE: URL scheme should be adopted when documentation team decided how
manual will be scructured.
2017-06-06 10:51:22 +03:00
Alexander Bruy
a137a7c0f3 [processing] open help in the default webbrowser to be consistent with
the rest of QGIS dialogs
2017-06-06 10:51:22 +03:00
Nyall Dawson
c1d35a043b Port getHTMLOutputsCount to c++ API 2017-06-06 15:39:54 +10:00
Nyall Dawson
2f28736e8e Remove some unused code 2017-06-06 14:38:52 +10:00
Nyall Dawson
d7aa3f5f7c [processing] Change explicit encoding string parameters to more
flexible QVariantMap creatOptions parameters which include an
optional fileEncoding value

More flexible, allows sinks to be created using any creation
option which is passed to the underlying provider
2017-06-06 08:00:28 +10:00
Nyall Dawson
7683b25f81 Move getFileFilter from params to gui wrappers 2017-06-06 07:41:20 +10:00
Nyall Dawson
a658135693 Remove global processing use selection setting 2017-06-06 07:41:20 +10:00
Nyall Dawson
bdf051a03a Partially port a trial python alg to new API 2017-06-06 07:41:19 +10:00
Nyall Dawson
0c3ad14c79 Adapt more python code to new API 2017-06-06 07:41:19 +10:00
Nyall Dawson
28f7a8b7e1 Move expression context generation out of parameters 2017-06-06 07:41:19 +10:00
Nyall Dawson
416770b197 Remove no longer required _resolveLayers method 2017-06-06 07:41:19 +10:00
Nyall Dawson
ba03f1a13a Move minimum layer extent calculation to c++ 2017-06-06 07:41:19 +10:00
Nyall Dawson
189f804714 Adapt more code to c++ API 2017-06-06 07:41:19 +10:00
Nyall Dawson
ef59d0c454 Port parameter checking to c++ 2017-06-06 07:41:19 +10:00
Nyall Dawson
c1d9d57dd2 First working pure c++ algorithms 2017-06-06 07:41:19 +10:00
Nyall Dawson
4cb7d18b1c Push parameters into processAlgorithm and related functions 2017-06-06 07:41:19 +10:00
Nyall Dawson
9997ab6e1e Partially port wrappers to QgsProcessingParameterDefinition
And create a new WidgetWrapperFactory for creating a suitable wrapper
corresponding to a parameter
2017-06-06 07:41:19 +10:00
Nyall Dawson
77ab933788 Move alg character definitions to __init__ 2017-06-06 07:41:19 +10:00
Nyall Dawson
134c04b8bb Move getParametersPanel out of algorithm class
It's a gui related method, so shouldn't be in core class
2017-06-06 07:41:19 +10:00
Nyall Dawson
168f16276c Remove help related methods from GeoAlgorithm 2017-06-06 07:41:19 +10:00
Nyall Dawson
2d1579d28a Port algorithm help to QgsProcessingAlgorithm 2017-06-06 07:41:19 +10:00
Nyall Dawson
1e788556f0 Port getCustomParametersDialog to QgsProcessingAlgorithm 2017-06-06 07:41:19 +10:00
Nyall Dawson
fb811766f8 Add framework for algorithm outputs
This somewhat changes the meaning of outputs from processing 2.x.
In 2.x processing outputs were used both as a method of specifying
inputs to algorithms (file paths to destination layers created
by the algorithm) AND pure outputs (such as statistics calculated
by the algorithm).

This is now split. The old input-type-outputs (destination layers)
are now input parameters (since the parameter value IS an input to the
algorithm). To differentiate them from parameters indicating pure
input layers a new "isDestination()" method was added to
QgsProcessingParameterDefinition.

Output definitions are now purely indications of values CREATED
by the algorithms. Suitable candidates are the existing calculated
stats and actual file path/URI of any layers created by the algorithm.
Moving forward we should ensure all algorithms output as much
useful information as possible - e.g. number of features processed,
number of skipped features, count null geometries encountered, etc...
2017-06-06 07:41:19 +10:00
Nyall Dawson
fac8ca4d4f Move execution check to QgsProcessingAlgorithm 2017-06-06 07:41:19 +10:00
Nyall Dawson
03e40f7497 [processing] Remove all remaining algorithm copies
Algorithms are no longer copied - just a single const instance
of each algorithm is used
2017-06-06 07:41:19 +10:00