Skip to content

Commit

Permalink
ensures that "gda:rasterize" uses integer numbers as input to -ts par…
Browse files Browse the repository at this point in the history
…ameter

fixes #60524
  • Loading branch information
jakimowb committed Feb 10, 2025
1 parent 15f06f1 commit fd61e5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions python/plugins/processing/algs/gdal/rasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,12 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
units = self.parameterAsEnum(parameters, self.UNITS, context)
if units == 0:
arguments.append("-ts")
arguments.append(self.parameterAsInt(parameters, self.WIDTH, context))
arguments.append(self.parameterAsInt(parameters, self.HEIGHT, context))
else:
arguments.append("-tr")
arguments.append(self.parameterAsDouble(parameters, self.WIDTH, context))
arguments.append(self.parameterAsDouble(parameters, self.HEIGHT, context))
arguments.append(self.parameterAsDouble(parameters, self.WIDTH, context))
arguments.append(self.parameterAsDouble(parameters, self.HEIGHT, context))

if self.INIT in parameters and parameters[self.INIT] is not None:
initValue = self.parameterAsDouble(parameters, self.INIT, context)
Expand Down
22 changes: 11 additions & 11 deletions python/plugins/processing/tests/GdalAlgorithmsRasterTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3332,7 +3332,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -ot Float32 -of JPEG "
"-l polys2 -a id -ts 0 0 -ot Float32 -of JPEG "
+ source
+ " "
+ outdir
Expand All @@ -3353,7 +3353,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -a_nodata 9999.0 -ot Float32 -of JPEG "
"-l polys2 -a id -ts 0 0 -a_nodata 9999.0 -ot Float32 -of JPEG "
+ source
+ " "
+ outdir
Expand All @@ -3374,7 +3374,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -init 0.0 -ot Float32 -of JPEG "
"-l polys2 -a id -ts 0 0 -init 0.0 -ot Float32 -of JPEG "
+ source
+ " "
+ outdir
Expand All @@ -3395,7 +3395,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -a_nodata 0.0 -ot Float32 -of JPEG "
"-l polys2 -a id -ts 0 0 -a_nodata 0.0 -ot Float32 -of JPEG "
+ source
+ " "
+ outdir
Expand All @@ -3416,7 +3416,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -ot Float32 -of JPEG -at -add "
"-l polys2 -a id -ts 0 0 -ot Float32 -of JPEG -at -add "
+ source
+ " "
+ outdir
Expand All @@ -3433,7 +3433,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l pointsz -3d -ts 0.0 0.0 -ot Float32 -of JPEG "
"-l pointsz -3d -ts 0 0 -ot Float32 -of JPEG "
+ sourceZ
+ " "
+ outdir
Expand All @@ -3455,7 +3455,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l pointsz -3d -ts 0.0 0.0 -ot Float32 -of JPEG "
"-l pointsz -3d -ts 0 0 -ot Float32 -of JPEG "
+ sourceZ
+ " "
+ outdir
Expand All @@ -3477,7 +3477,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -te -1.0 -3.0 10.0 6.0 -ot Float32 -of JPEG "
"-l polys2 -a id -ts 0 0 -te -1.0 -3.0 10.0 6.0 -ot Float32 -of JPEG "
+ source
+ " "
+ outdir
Expand All @@ -3498,7 +3498,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -te -1.000000001857055 -2.9999999963940835 10.000000000604246 5.999999999604708 -ot Float32 -of JPEG "
"-l polys2 -a id -ts 0 0 -te -1.000000001857055 -2.9999999963940835 10.000000000604246 5.999999999604708 -ot Float32 -of JPEG "
+ source
+ " "
+ outdir
Expand All @@ -3520,7 +3520,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -ot Float32 -of JPEG -oo X_POSSIBLE_NAMES=geom_x -oo Y_POSSIBLE_NAMES=geom_y "
"-l polys2 -a id -ts 0 0 -ot Float32 -of JPEG -oo X_POSSIBLE_NAMES=geom_x -oo Y_POSSIBLE_NAMES=geom_y "
+ source
+ " "
+ outdir
Expand All @@ -3540,7 +3540,7 @@ def testRasterize(self):
),
[
"gdal_rasterize",
"-l polys2 -a id -ts 0.0 0.0 -ot Float32 -of JPEG --config X Y --config Z A "
"-l polys2 -a id -ts 0 0 -ot Float32 -of JPEG --config X Y --config Z A "
+ source
+ " "
+ outdir
Expand Down

0 comments on commit fd61e5c

Please sign in to comment.