88 Commits

Author SHA1 Message Date
Mathieu Pellerin
f2289c83f1 [processing] Fix feature iteration against a model (fixes #60131) 2025-01-28 12:06:36 +10:00
Denis Rouzaud
0f032e5f2d run pre-commit on all files 2024-11-29 15:38:02 +01:00
Nyall Dawson
c16a1e2b3d Update enums 2024-01-19 19:44:48 +10:00
Nyall Dawson
26ce45d6d5 Remove unused argument 2023-05-03 18:29:28 +10:00
Etienne Trimaille
3cab3c43a2
Python - Run pyupgrade on the processing plugin 2023-04-24 10:03:57 +02:00
Alessandro Pasotti
bc3e4ca7fe Set parents and factor out GUI alg executor 2021-11-30 21:06:57 +10:00
Nyall Dawson
3ae96253de [processing] Fix use of data defined parameter values when editing
features in place

Fixes #43758
2021-06-17 13:18:12 +10:00
Matthias Kuhn
60ad7d43b3 Fix calling in place with empty iterator
```
              File "/home/mkuhn/.local/share/QGIS/QGIS3/profiles/default/python/plugins/autocurve/plugin.py", line 127, in curvify
              AlgorithmExecutor.execute_in_place(alg, {})
              File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 305, in execute_in_place
              ok, results = execute_in_place_run(alg, parameters, context=context, feedback=feedback)
              File "/usr/share/qgis/python/plugins/processing/gui/AlgorithmExecutor.py", line 214, in execute_in_place_run
              results, ok = {'__count': current + 1}, True
              UnboundLocalError: local variable 'current' referenced before assignment
```
2021-02-22 15:06:19 +01:00
Nyall Dawson
f5d3164e2c [processing] Input parameter name for in place algorithms is not
always fixed, so ensure we correctly obtain and use the correct
input parameter name
2021-02-03 12:38:35 +10:00
Juergen E. Fischer
5a2757729a translation string fix 2020-10-25 22:00:42 +01:00
Nyall Dawson
db7b977059 [processing] Correctly discard fid field values when running
algorithms with the RegeneratePrimaryKey flag in in-place mode

Fixes #37761, fixes #33816
2020-10-16 05:04:08 +10:00
Nyall Dawson
2207c30a24 When calling processing.run() and an QgsProcessingExpection occurs,
don't raise a generic "something went wrong" exception but instead
ensure that the original exception with the proper error message
is raised for catching in Python instead
2020-10-09 05:17:49 +10:00
Matthias Kuhn
d41e8e1d40 Rename count to __count 2020-09-15 06:48:37 +10:00
Matthias Kuhn
d2c60cca30 Add count to "tradition run in place execution" 2020-09-15 06:48:37 +10:00
Matthias Kuhn
656c533fa2 Show number of features affected by in place editing
Fixes #38680
2020-09-15 06:48:37 +10:00
Nyall Dawson
2104ae613a [processing] Add mechanism for algorithms to alter their core behavior
(e.g. parameters) when they are run in the "edit in-place" mode

This allows algorithms to dynamically adapt their behavior to make them compatible
with in-place mode. Previously, some useful algorithms could not be
run in-place because they alter a layer's structure (e.g. adding new
fields).

Now, these algorithms have a means to detect that they are being
run in-place and change their input parameters accordingly. E.g.
an algorithm which usually adds new fields to store calculated
values (such as "add xy fields to layer") could instead expose
field parameter choices to ask the user to pick from existing
fields in which to store the calculated values, thereby avoiding
the need to change the table structure and making them eligable
for running in-place mode.

Note that this needs to be handled algorithm-by-algorithm, it's
not automatic! It's just the raw api to allow this...
2020-07-28 14:18:20 +10:00
Matthias Kuhn
a7e0831dcf Code style 2020-05-05 22:38:37 +02:00
uclaros
f2353ec934 Make progress count from 0 to 100 2020-04-27 13:41:58 +10:00
Alessandro Pasotti
04f0879ed5 Processing editing in place: handle constraints
Fixes #31634
2019-09-16 10:41:58 +10:00
Nyall Dawson
1537f83614 Fix some algorithms fail to execute correctly in in-place mode 2019-09-06 05:29:08 +10:00
Bas Couwenberg
2628c480c5 Don't include revision in sources.
Prevent changes to files that weren't changed between releases.
This eases review of the changes between releases significantly.
2019-05-17 16:47:47 +02:00
Alessandro Pasotti
a9652316af Tiny cosmetic fix: error by 1 on iteration counter text 2019-02-23 15:30:57 +01:00
Alessandro Pasotti
40fb2ce93d Drop the ugly hack in favor of sourceFlags 2018-12-21 13:20:41 +01:00
Alessandro Pasotti
f4d7506e73 Processing in-place do not check validity when fixing geometries
Fixes #20812
2018-12-21 11:47:36 +01:00
Alessandro Pasotti
dcd33186bb [in-place] Fix alg runner when context is none 2018-10-20 10:05:48 +02:00
Alessandro Pasotti
adb930b204 Speed up getFeatures query by using a proper QgsFeatureRequest 2018-10-19 16:27:18 +02:00
Alessandro Pasotti
71e2a6be7e In-place passthrough for invalid geometries if processing option is to skip invalid
Fixes #20147 - difference deletes invalid geometries
2018-10-18 17:43:00 +02:00
Alessandro Pasotti
29c4970f8a [processing] In-place add layer name to dlg title and store active layer 2018-10-05 10:10:20 +02:00
Alessandro Pasotti
ca1c65d07a [processing] In place editing triggers editing and select all
If the active layer is not editable, the executor will
try to switch editing on.

If there are no selected features, the executor will
select all features before running.
2018-10-05 08:53:30 +02:00
Nyall Dawson
c8bf6db363 [processing] Give progress reports/allow cancelation in in-place mode 2018-10-02 16:46:16 +10:00
Nyall Dawson
08cece22b0 [processing] Fix some exceptions when running in iterate mode 2018-10-01 16:13:38 +10:00
Alessandro Pasotti
930c3f8e45 Port makeFeaturesCompatible to C++
as: QgsVectorLayerUtils::makeFeaturesCompatible

With tests.
2018-09-25 08:17:14 +02:00
Nyall Dawson
9fcd4fd00c Use QgsVectorLayerUtils.matchAttributesToFields in processing in-place edits 2018-09-25 08:49:21 +10:00
Nyall Dawson
e2068b8c1f [processing] Pass a copy of the feature to processFeature, not
the original layer's feature

Otherwise python processFeature implementations may return a
modified shallow copy of this feature, which means that the
test for modifications fails, since we're comparing against
the same feature which was modified.

Fixes some python algorithms do not modify features when used
in-place mode.
2018-09-21 18:02:21 +10:00
Nyall Dawson
f51487551b [processing] Use display name, not alg ID in undo history for in-place mode 2018-09-18 08:27:33 +10:00
Alessandro Pasotti
a60324b79b Accept geometry-less features in a geometry layer 2018-09-14 18:23:03 +10:00
Alessandro Pasotti
699a9a3bfb Raise exception if prepare fails 2018-09-14 18:23:03 +10:00
Alessandro Pasotti
e01449f5c5 Handle bad/null geometries and geometryless 2018-09-14 18:23:03 +10:00
Alessandro Pasotti
7b162b535f Feature fixer: multi part to single part 2018-09-14 18:23:03 +10:00
Alessandro Pasotti
08f79bed43 More tests for Z/M add back 2018-09-14 18:23:03 +10:00
Alessandro Pasotti
4549ee5fff In-place moved check logic into QgsAlgorithm
+ new tests
+ fixed fixer function
+ drop z/m
2018-09-14 18:23:03 +10:00
Alessandro Pasotti
11aaf90393 Function to make output features compatible 2018-09-14 18:23:03 +10:00
Nyall Dawson
681d44f11f Messy mockup of feature 2018-09-14 18:23:03 +10:00
Juergen E. Fischer
6dfedc38e9 translation string fixes and cleanups 2018-02-15 22:31:15 +01:00
Denis Rouzaud
3dc3d9d1b2 unite QgsMessageLog::Level and QgsMessageBar::MessageLevel in Qgis::MessageLevel
make enum items lower case
remove unused QgsMessageLog::None and All
2018-02-06 08:56:40 -04:00
Alexander Bruy
0059b2b692 [processing] remove Python 2 compatibility layer 2017-11-28 12:27:45 +02:00
Alexander Bruy
56208540f9 [processing] remove GeoAlgorithmExecutionException 2017-07-13 09:02:24 +03: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
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