Skip to content

Commit

Permalink
[OTB] Fixes empty string parameters (#40957)
Browse files Browse the repository at this point in the history
(cherry picked from commit 579d55f)
  • Loading branch information
troopa81 authored and nyalldawson committed Jan 13, 2021
1 parent 3de1b34 commit 6c2b26e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/otb/OtbAlgorithm.py
Expand Up @@ -201,8 +201,8 @@ def processAlgorithm(self, parameters, context, feedback):
command = '"{}" {} {}'.format(app_launcher_path, self.name(), OtbUtils.appFolder())
outputPixelType = None
for k, v in parameters.items():
# if value is None for a parameter we don't have any businees with this key
if v is None:
# if value is None or en empty string for a parameter then we don't want to pass that value to OTB (see https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2130)
if v == '' or v is None:
continue
# for 'outputpixeltype' parameter we find the pixeltype string from self.pixelTypes
if k == 'outputpixeltype':
Expand Down
16 changes: 16 additions & 0 deletions python/plugins/processing/tests/testdata/otb_algorithm_tests.yaml
Expand Up @@ -64,3 +64,19 @@ tests:
out:
hash: 987b1488daaa16d09ad6f40039ee85101c557354a4d821d3f31ad235
type: rasterhash

- algorithm: otb:Rasterization
name: Test empty string and zero integer parameters (otb:Rasterization)
params:
in:
name: polys.gml
type: file
epsg: EPSG:4326
spx: 1
spy: 1
mode.attribute.field: ""
outputpixeltype: 0
results:
out:
hash: c898326f9327dd0a111532fdacc5f43fc485ae3e10f1238b5da04dde
type: rasterhash

0 comments on commit 6c2b26e

Please sign in to comment.