6928 Commits

Author SHA1 Message Date
Nyall Dawson
7f7c7a9789 [processing][needs-docs] Add friendlier API for running algorithms as sub-steps
of main algorithm

Using code like:

    buffered_layer = processing.run(..., context, feedback)['OUTPUT']
    ...
    return {'OUTPUT': buffered_layer}

can cause issues if done as a sub-step of a larger processing algorithm. This
is because ownership of the generated layer is transferred to the caller
(Python) by processing.run. When the algorithm returns, Processing
attempts to move ownership of the layer from the context to the caller,
resulting in a crash.

(This is by design, because processing.run has been optimised for the
most common use case, which is one-off execution of algorithms as part
of a script, not as part of another processing algorithm. Accordingly
by design it returns layers and ownership to the caller, making things
easier for callers as they do not then have to resolve the layer reference
from the context object and handle ownership themselves)

This commit adds a new "is_child_algorithm" argument to processing.run.
For algorithms which are executed as sub-steps of a larger algorithm
is_child_algorithm should be set to True to avoid any ownership issues
with layers. E.g.

    buffered_layer = processing.run(..., context, feedback, is_child_algorithm=True)['OUTPUT']
    ...
    return {'OUTPUT': buffered_layer}
2019-01-29 18:04:16 +11:00
Víctor Olaya
6eaa511eed [processing] show warning when file-based layer could not be loaded and dependent params updated
For algorithms with multiple parameters depending on a vector layer parameter, the code that loads the layer in the background is called repeatedly, impacting performance. A small layer cache is implemented with these changes, so the dialog only tries to load the layer once.
2019-01-29 11:12:23 +11:00
Alexander Bruy
8446d3bdf0 [processing][needs-docs] native vector split algorithm now outputs
GeoPackages instead of shapefiles (refs #20557)

Also remove default output extension Processing settings as they are not
used anymore.
2019-01-29 11:05:37 +11:00
Víctor Olaya
1b4a9132c2 [processing] avoid exception when listing DB schemas
do not fail if cert file cannot be deleted when creating GeoDB object

fixes #21099
2019-01-29 08:01:20 +11:00
Juergen E. Fischer
febbc4f0b9 osgeo4w: handle grass svn versions (fixes #21114) 2019-01-27 17:37:39 +01:00
Nyall Dawson
431861a468 [processing] Add a better API for specifying that outputs are temporary
Instead of requiring clients to generate temporary file names themselves,
(or use the cryptic "memory:" string!), this PR adds a static constant

    QgsProcessing.TEMPORARY_OUTPUT

If a layer/sink output parameter is set to QgsProcessing.TEMPORARY_OUTPUT,
then the temporary output filename will be generated automatically at
algorithm run time. This means callers don't need to mess around with
finding appropriate temporary folders and paths.

Another benefit is that TEMPORARY_OUTPUT is stored in the processing
history, so if you re-run a previous algorithm which was set to
output to a temporary file, it no longer tries to use that same
previous temporary path and instead generates a new one.
2019-01-25 23:27:08 +11:00
Alexander Bruy
a90fb87c8e
Merge pull request #8973 from alexbruy/grass-buffer
[processing] fix GRASS v.buffer algorithm for variable buffer case (fix #19377)
2019-01-25 12:49:12 +02:00
Nyall Dawson
3cb6a40ef2 [processing] Add API to get an import statement and classname for a parameter type 2019-01-25 18:12:11 +11:00
Alexander Bruy
8919d604a8 [processing] use background color from the project settings in the rasterize algorithm (fix #19866) 2019-01-25 10:06:12 +11:00
Alexander Bruy
32f6034be7 [processing][needs-docs] force multipart output from GDAL-based dissolve
algorithm (fix #20025)
2019-01-25 09:57:31 +11:00
Alexander Bruy
bfb60e4dc7 [processing] fix GRASS v.buffer algorithm for case when buffer distance
is taken from the field (fix #19377)
2019-01-24 21:01:12 +02:00
Matthias Kuhn
7482f7a448
Merge pull request #8957 from volaya/#19607
[processing] do not allow editing model if it's missing algorithms
2019-01-24 19:53:12 +01:00
Matthias Kuhn
9bdaac9dd0
Update python/plugins/processing/modeler/EditModelAction.py
Co-Authored-By: volaya <volayaf@gmail.com>
2019-01-24 10:50:19 +01:00
Alexander Bruy
c6540a6276 [processing] fix description files for SVM SAGA algs (fix #20796) 2019-01-24 09:31:18 +11:00
Alexander Bruy
34ec183354 [processing] split v.surf.rst algorithm into two (fix #19472)
This algorithm cannot output cross-validation results and topographic
parameters simultaneously, hence two tools needed. Thanks to Pedro Venâncio
for finding this and proposing a fix.
2019-01-24 06:45:23 +11:00
Ailurupoda
aa3679a3cf Update layout oracle connector.py 2019-01-23 14:25:05 +01:00
volaya
a86965e94b [processing] do not allow editing model if it's missing algorithms
fixes #19607
2019-01-23 14:02:42 +01:00
Corentin.F
a80f3d01ee
Merge branch 'master' into sirs_db_manager 2019-01-23 11:22:12 +01:00
Ailurupoda
00852f1642 Update oracle, vlayer, spatialite connector.py 2019-01-23 11:20:24 +01:00
Ailurupoda
ad81e66daa Update gpkg UpdateTableColumn add argument new_comment 2019-01-23 10:48:16 +01:00
volaya
e3516ab1b4 [processing] fixed qgis algorithms help file
fixes #20966
2019-01-23 08:38:41 +01:00
Nyall Dawson
db3b9aeb6b Revert "[processing] hide 'select file' button for vector layers when there are dependent params"
This reverts commit f2044528951bbb09a70b9c696d79d8cd5b756214.

It's a contentious fix, which needs discussion
2019-01-23 17:30:47 +10:00
volaya
eb47288fac [processing] correctly set output styles for models
fixes #20573
2019-01-23 08:02:19 +01:00
volaya
f204452895 [processing] hide 'select file' button for vector layers when there are dependent params
fixes #21055
2019-01-23 08:02:18 +01:00
Alexander Bruy
0c4c8feb70
Merge pull request #8945 from alexbruy/processing-fieldcalc
[processing] use active layer by default in field calculator algorithm (fix #19686)
2019-01-22 15:25:20 +02:00
Alexander Bruy
3a98174640
Merge pull request #8942 from alexbruy/processing-interpolation
[processing] use complex delimiter for interpolation data (fix #20490)
2019-01-22 14:03:57 +02:00
Alexander Bruy
95209d134c [processing] use active layer by default in field calculator algorithm
(fix #19686)
2019-01-22 11:04:49 +02:00
Alexander Bruy
17fd86e723 [processing] use complex delimiter for interpolation data to avoid
overlaps with charactes which can be used in the layers source URI (fix #20490)
2019-01-22 10:15:07 +02:00
Alexander Bruy
133b4057a6 add note about format of the srcnodata parameter 2019-01-22 08:18:37 +02:00
Alexander Bruy
dc2b29ce6a [processing] add missed "srcnodata" parameter to the buildvrt algorithm
(fix #20586).

Without this parameter it is not possible to remove collars surrounding
input raster which may overlap with other input rasters. As this is very
frequent case algorithm is useless without such parameter. To keep API
compatibility new parameter is optional and not used by default.
2019-01-22 08:17:47 +02:00
Nyall Dawson
ee34431214 Use a QHash instead of std::unordered_map
Because it turns out MUCH MUCH faster
2019-01-22 13:14:03 +11:00
Alexander Bruy
bb2c3663b0 [processing] add optional EXTRA parameter to gdalwarp algorithm (fix #20721)
This allows users to pass additional command-line arguments which are
not exposed in the algorithm definition. The most frequent use case is
enabling transparency and adding nodata values.
2019-01-22 09:39:57 +11:00
Julien Cabieces
49cb397f89 Update layer statistics when adding column to table in order to be displayed by QGIS
fixes #13504
2019-01-22 07:54:12 +11:00
Corentin.F
9184a5b273
Update connector.py 2019-01-21 15:50:24 +01:00
corentin.falcone
11948283e1 update correction 2019-01-21 11:51:03 +01:00
Matthias Kuhn
9452667af3
Add native densify by interval algorithm 2019-01-21 09:49:38 +01:00
Matthias Kuhn
8db14d8fc2
Merge pull request #8906 from m-kuhn/native_polygons_to_lines
Add native polygonstolines algorithm
2019-01-21 09:11:01 +01:00
Nyall Dawson
195d98f43a [needs-docs][processing] Port SAGA raster surface volume to native QGIS alg
The SAGA version of this algorithm is of limited use in QGIS, because the
volume calculated is embedded only in the SAGA terminal output. This prevents
it being saved to a file, or reused within a model as an input to a later
model step.

It's also very user-unfriendly, because users must know to manually scan
the algorithm log to find the SAGA output.

Given that the maths here is trivial, this commit ports the algorithm across
to be a native QGIS c++ algorithm. The algorithm duplicates the SAGA alg
1:1, but outputs the volume (and area) to either a HTML report, or a vector
table. Additionally, the outputs are exported as numeric outputs from the
algorithm, allowing them to be re-used within models.

(It's also considerably faster, because it avoids the forced conversion
to SAGA raster format)

Fixes #8607 (properly, even though that report is closed)
2019-01-21 12:33:54 +11:00
Markus Neteler
8db3dead87
Complete grass76 support 2019-01-19 22:08:28 +01:00
Matthias Kuhn
4c8af20b51
Add native polygonstolines algorithm 2019-01-18 19:07:08 +01:00
Ivan Ivanov
2488f71ddb Added test for 'gdal_rasterize -init 0' 2019-01-18 09:50:08 +11:00
Ivan Ivanov
36c821da34 Allow gdal_rasterize to accept -init with value of 0; changed default value to not introduce a breaking change 2019-01-18 09:50:08 +11:00
Nyall Dawson
f89d061ba0 [FEATURE][processing] Add geodesic mode for "Join by Lines (Hub lines)" algorithm
This allows optional creation of geodesic lines, which represent the
shortest distance between the points based on the ellipsoid.

When geodesic mode is used, it is possible to split the created lines
at the antimeridian (±180 degrees longitude), which can improve
rendering of the lines. Additionally, the distance between vertices
can be specified. A smaller distance results in a denser, more accurate
line.
2019-01-17 03:39:20 +11:00
Mathieu Pellerin
6957009f8b [themes] Fix the processing modeler's rendering on dark backgrounds 2019-01-15 12:24:50 +07:00
Nyall Dawson
629de0c651 Fix some corner cases 2019-01-12 05:31:00 +10:00
Nyall Dawson
2a774d6dac [FEATURE][processing] New algorithm "Geodesic line split at antimeridian"
Ports the similar algorithm from the shape tools plugin to c++, and utilises
built in QgsDistanceArea ellipsoidal calculations to split the lines.

This algorithm splits a line into multiple geodesic segments, whenever the
line crosses the antimeridian (±180 degrees longitude)

Splitting at the antimeridian helps the visual display of the lines in some
projections. The returned geometry will always be a multi-part geometry.

Whenever line segments in the input geometry cross the antimeridian,
they will be split into two segments, with the latitude of the breakpoint
being determined using a geodesic line connecting the points either side
of this segment. The current project ellipsoid setting will be used when
calculating this breakpoint.

If the input geometry contains M or Z values, these will be linearly
interpolated for the new vertices created at the antimeridian.

Supports in-place edit mode also.
2019-01-12 05:31:00 +10:00
corentin.falcone
911a36119a Update travis building 2019-01-11 14:30:10 +01:00
corentin.falcone
c0dd72ee8b Update travis building 2019-01-11 14:15:46 +01:00
corentin.falcone
7852a7a71a Update building 2019-01-11 11:56:01 +01:00
corentin.falcone
94784a5cf8 Update building 2019-01-11 11:10:02 +01:00