Skip to content

Commit

Permalink
Merge pull request #54035 from alexbruy/processing-port-raster-calcul…
Browse files Browse the repository at this point in the history
…ator

Port Raster Calculator algorithm to C++
  • Loading branch information
alexbruy committed Sep 30, 2023
2 parents dece451 + 8793e65 commit 373d5f8
Show file tree
Hide file tree
Showing 21 changed files with 1,818 additions and 34 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -127,6 +127,7 @@
<file>themes/default/algorithms/mAlgorithmRandomPointsWithinExtent.svg</file>
<file>themes/default/algorithms/mAlgorithmRandomPoissonRaster.svg</file>
<file>themes/default/algorithms/mAlgorithmRandomRaster.svg</file>
<file>themes/default/algorithms/mAlgorithmRasterCalculator.svg</file>
<file>themes/default/algorithms/mAlgorithmRegularPoints.svg</file>
<file>themes/default/algorithms/mAlgorithmRoundRastervalues.svg</file>
<file>themes/default/algorithms/mAlgorithmSelectLocation.svg</file>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion python/core/auto_additions/qgis.py
Expand Up @@ -3762,7 +3762,8 @@
# monkey patching scoped based enum
Qgis.ExpressionType.Qgis.__doc__ = "Native QGIS expression"
Qgis.ExpressionType.PointCloud.__doc__ = "Point cloud expression"
Qgis.ExpressionType.__doc__ = "Expression types\n\n.. versionadded:: 3.32\n\n" + '* ``Qgis``: ' + Qgis.ExpressionType.Qgis.__doc__ + '\n' + '* ``PointCloud``: ' + Qgis.ExpressionType.PointCloud.__doc__
Qgis.ExpressionType.RasterCalculator.__doc__ = "Raster calculator expression (since QGIS 3.34)"
Qgis.ExpressionType.__doc__ = "Expression types\n\n.. versionadded:: 3.32\n\n" + '* ``Qgis``: ' + Qgis.ExpressionType.Qgis.__doc__ + '\n' + '* ``PointCloud``: ' + Qgis.ExpressionType.PointCloud.__doc__ + '\n' + '* ``RasterCalculator``: ' + Qgis.ExpressionType.RasterCalculator.__doc__
# --
Qgis.ExpressionType.baseClass = Qgis
QgsVectorFileWriter.SymbologyExport = Qgis.FeatureSymbologyExport
Expand Down
1 change: 1 addition & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -2163,6 +2163,7 @@ The development version
{
Qgis,
PointCloud,
RasterCalculator,
};

enum class FeatureSymbologyExport
Expand Down
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/qgis/RasterCalculator.py
Expand Up @@ -24,6 +24,7 @@
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils
from qgis.core import (QgsProcessing,
QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingUtils,
QgsProcessingParameterCrs,
Expand Down Expand Up @@ -88,6 +89,9 @@ def clone(self):
self.addParameter(QgsProcessingParameterCrs(self.CRS, 'Output CRS', optional=True))
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT, self.tr('Output')))

def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagDeprecated

def name(self):
return 'rastercalculator'

Expand Down
Expand Up @@ -1190,7 +1190,7 @@ tests:
- 'Maximum value: 15:29:22'
- 'NULL \(missing\) values: 1'

- algorithm: qgis:rastercalculator
- algorithm: native:rastercalc
name: Raster Calculator with cellsize
params:
LAYERS:
Expand All @@ -1199,13 +1199,14 @@ tests:
type: raster
type: multi
CELLSIZE: 0.001
EXPRESSION: dem@1
EXPRESSION: '"dem.tif@1"'
results:
OUTPUT:
hash: 525577c05dd999239d9c6f95fd5e70d96355da3a0ea71bfcf021e729
hash: 6ced822cc490c7a3d9346b6c8cd4b282eb4e2a9fdd6e7371f6174117
type: rasterhash

- algorithm: qgis:rastercalculator
- algorithm: native:rastercalc
name: Raster Calculator
params:
LAYERS:
Expand All @@ -1214,7 +1215,7 @@ tests:
type: raster
type: multi
CELLSIZE: 0.0
EXPRESSION: dem@1 * 2
EXPRESSION: '"dem.tif@1" * 2'
results:
OUTPUT:
hash: 98daf025230ec9d031f7502c6a80a3b04dd060808d6b7bcb4328e87c
Expand Down
2 changes: 2 additions & 0 deletions src/analysis/CMakeLists.txt
Expand Up @@ -169,6 +169,7 @@ set(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmrandompointsinpolygons.cpp
processing/qgsalgorithmrandompointsonlines.cpp
processing/qgsalgorithmrandomraster.cpp
processing/qgsalgorithmrastercalculator.cpp
processing/qgsalgorithmrasterdtmslopebasedfilter.cpp
processing/qgsalgorithmrasterfrequencybycomparisonoperator.cpp
processing/qgsalgorithmrasterlayerproperties.cpp
Expand Down Expand Up @@ -238,6 +239,7 @@ set(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmunion.cpp
processing/qgsalgorithmuniquevalueindex.cpp
processing/qgsalgorithmvectorize.cpp
processing/qgsalgorithmvirtualrastercalculator.cpp
processing/qgsalgorithmwedgebuffers.cpp
processing/qgsalgorithmwritevectortiles.cpp
processing/qgsalgorithmxyztiles.cpp
Expand Down

0 comments on commit 373d5f8

Please sign in to comment.