Skip to content

Commit

Permalink
Move resampling method enum to Qgis, promote to enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 9, 2024
1 parent de6e2dc commit c607dad
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 215 deletions.
54 changes: 50 additions & 4 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2716,20 +2716,66 @@
# monkey patching scoped based enum
QgsRasterPipe.ResampleFilter = Qgis.RasterResamplingStage.ResampleFilter
QgsRasterPipe.ResampleFilter.is_monkey_patched = True
QgsRasterPipe.ResampleFilter.__doc__ = ""
QgsRasterPipe.ResampleFilter.__doc__ = "Resampling occurs in ResamplingFilter"
QgsRasterPipe.Provider = Qgis.RasterResamplingStage.Provider
QgsRasterPipe.Provider.is_monkey_patched = True
QgsRasterPipe.Provider.__doc__ = ""
QgsRasterPipe.Provider.__doc__ = "Resampling occurs in Provider"
Qgis.RasterResamplingStage.__doc__ = """Stage at which raster resampling occurs.

.. versionadded:: 3.22

* ``ResampleFilter``:
* ``Provider``:
* ``ResampleFilter``: Resampling occurs in ResamplingFilter
* ``Provider``: Resampling occurs in Provider

"""
# --
Qgis.RasterResamplingStage.baseClass = Qgis
QgsRasterDataProvider.ResamplingMethod = Qgis.RasterResamplingMethod
# monkey patching scoped based enum
QgsRasterDataProvider.Nearest = Qgis.RasterResamplingMethod.Nearest
QgsRasterDataProvider.Nearest.is_monkey_patched = True
QgsRasterDataProvider.Nearest.__doc__ = "Nearest-neighbour resampling"
QgsRasterDataProvider.Bilinear = Qgis.RasterResamplingMethod.Bilinear
QgsRasterDataProvider.Bilinear.is_monkey_patched = True
QgsRasterDataProvider.Bilinear.__doc__ = "Bilinear (2x2 kernel) resampling"
QgsRasterDataProvider.Cubic = Qgis.RasterResamplingMethod.Cubic
QgsRasterDataProvider.Cubic.is_monkey_patched = True
QgsRasterDataProvider.Cubic.__doc__ = "Cubic Convolution Approximation (4x4 kernel) resampling"
QgsRasterDataProvider.CubicSpline = Qgis.RasterResamplingMethod.CubicSpline
QgsRasterDataProvider.CubicSpline.is_monkey_patched = True
QgsRasterDataProvider.CubicSpline.__doc__ = "Cubic B-Spline Approximation (4x4 kernel)"
QgsRasterDataProvider.Lanczos = Qgis.RasterResamplingMethod.Lanczos
QgsRasterDataProvider.Lanczos.is_monkey_patched = True
QgsRasterDataProvider.Lanczos.__doc__ = "Lanczos windowed sinc interpolation (6x6 kernel)"
QgsRasterDataProvider.Average = Qgis.RasterResamplingMethod.Average
QgsRasterDataProvider.Average.is_monkey_patched = True
QgsRasterDataProvider.Average.__doc__ = "Average resampling"
QgsRasterDataProvider.Mode = Qgis.RasterResamplingMethod.Mode
QgsRasterDataProvider.Mode.is_monkey_patched = True
QgsRasterDataProvider.Mode.__doc__ = "Mode (selects the value which appears most often of all the sampled points)"
QgsRasterDataProvider.Gauss = Qgis.RasterResamplingMethod.Gauss
QgsRasterDataProvider.Gauss.is_monkey_patched = True
QgsRasterDataProvider.Gauss.__doc__ = "Gauss blurring"
Qgis.RasterResamplingMethod.__doc__ = """Resampling method for raster provider-level resampling.

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterDataProvider`.ResamplingMethod

.. versionadded:: 3.42

* ``Nearest``: Nearest-neighbour resampling
* ``Bilinear``: Bilinear (2x2 kernel) resampling
* ``Cubic``: Cubic Convolution Approximation (4x4 kernel) resampling
* ``CubicSpline``: Cubic B-Spline Approximation (4x4 kernel)
* ``Lanczos``: Lanczos windowed sinc interpolation (6x6 kernel)
* ``Average``: Average resampling
* ``Mode``: Mode (selects the value which appears most often of all the sampled points)
* ``Gauss``: Gauss blurring

"""
# --
Qgis.RasterResamplingMethod.baseClass = Qgis
# monkey patching scoped based enum
Qgis.RasterRendererFlag.InternalLayerOpacityHandling.__doc__ = "The renderer internally handles the raster layer's opacity, so the default layer level opacity handling should not be applied."
Qgis.RasterRendererFlag.UseNoDataForOutOfRangePixels.__doc__ = "Out of range pixels (eg those values outside of the rendered map's z range filter) should be set using additional nodata values instead of additional transparency values \n.. versionadded:: 3.38"
Expand Down
24 changes: 0 additions & 24 deletions python/PyQt6/core/auto_additions/qgsrasterdataprovider.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
# The following has been generated automatically from src/core/raster/qgsrasterdataprovider.h
QgsRasterDataProvider.TransformImageToLayer = QgsRasterDataProvider.TransformType.TransformImageToLayer
QgsRasterDataProvider.TransformLayerToImage = QgsRasterDataProvider.TransformType.TransformLayerToImage
# monkey patching scoped based enum
QgsRasterDataProvider.ResamplingMethod.Nearest.__doc__ = "Nearest-neighbour resampling"
QgsRasterDataProvider.ResamplingMethod.Bilinear.__doc__ = "Bilinear (2x2 kernel) resampling"
QgsRasterDataProvider.ResamplingMethod.Cubic.__doc__ = "Cubic Convolution Approximation (4x4 kernel) resampling"
QgsRasterDataProvider.ResamplingMethod.CubicSpline.__doc__ = "Cubic B-Spline Approximation (4x4 kernel)"
QgsRasterDataProvider.ResamplingMethod.Lanczos.__doc__ = "Lanczos windowed sinc interpolation (6x6 kernel)"
QgsRasterDataProvider.ResamplingMethod.Average.__doc__ = "Average resampling"
QgsRasterDataProvider.ResamplingMethod.Mode.__doc__ = "Mode (selects the value which appears most often of all the sampled points)"
QgsRasterDataProvider.ResamplingMethod.Gauss.__doc__ = "Gauss blurring"
QgsRasterDataProvider.ResamplingMethod.__doc__ = """Resampling method for provider-level resampling.
.. versionadded:: 3.16
* ``Nearest``: Nearest-neighbour resampling
* ``Bilinear``: Bilinear (2x2 kernel) resampling
* ``Cubic``: Cubic Convolution Approximation (4x4 kernel) resampling
* ``CubicSpline``: Cubic B-Spline Approximation (4x4 kernel)
* ``Lanczos``: Lanczos windowed sinc interpolation (6x6 kernel)
* ``Average``: Average resampling
* ``Mode``: Mode (selects the value which appears most often of all the sampled points)
* ``Gauss``: Gauss blurring
"""
# --
try:
QgsImageFetcher.__attribute_docs__ = {'finish': 'Emitted when the download completes\n\n:param legend: The downloaded legend image\n', 'progress': 'Emitted to report progress\n', 'error': 'Emitted when an error occurs\n'}
QgsImageFetcher.__signal_arguments__ = {'finish': ['legend: QImage'], 'progress': ['received: int', 'total: int'], 'error': ['msg: str']}
Expand Down
16 changes: 13 additions & 3 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,20 @@ The development version

enum class RasterResamplingStage /BaseType=IntEnum/
{
//! Resampling occurs in ResamplingFilter
ResampleFilter,
//! Resampling occurs in Provider
Provider
Provider,
};

enum class RasterResamplingMethod /BaseType=IntEnum/
{
Nearest,
Bilinear,
Cubic,
CubicSpline,
Lanczos,
Average,
Mode,
Gauss
};

enum class RasterRendererFlag /BaseType=IntFlag/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,19 +627,7 @@ Returns whether provider-level resampling is enabled.
.. versionadded:: 3.16
%End

enum class ResamplingMethod
{
Nearest,
Bilinear,
Cubic,
CubicSpline,
Lanczos,
Average,
Mode,
Gauss
};

virtual bool setZoomedInResamplingMethod( ResamplingMethod method );
virtual bool setZoomedInResamplingMethod( Qgis::RasterResamplingMethod method );
%Docstring
Set resampling method to apply for zoomed-in operations.

Expand All @@ -648,14 +636,14 @@ Set resampling method to apply for zoomed-in operations.
.. versionadded:: 3.16
%End

ResamplingMethod zoomedInResamplingMethod() const;
Qgis::RasterResamplingMethod zoomedInResamplingMethod() const;
%Docstring
Returns resampling method for zoomed-in operations.

.. versionadded:: 3.16
%End

virtual bool setZoomedOutResamplingMethod( ResamplingMethod method );
virtual bool setZoomedOutResamplingMethod( Qgis::RasterResamplingMethod method );
%Docstring
Set resampling method to apply for zoomed-out operations.

Expand All @@ -664,7 +652,7 @@ Set resampling method to apply for zoomed-out operations.
.. versionadded:: 3.16
%End

ResamplingMethod zoomedOutResamplingMethod() const;
Qgis::RasterResamplingMethod zoomedOutResamplingMethod() const;
%Docstring
Returns resampling method for zoomed-out operations.

Expand Down
54 changes: 50 additions & 4 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2686,20 +2686,66 @@
# monkey patching scoped based enum
QgsRasterPipe.ResampleFilter = Qgis.RasterResamplingStage.ResampleFilter
QgsRasterPipe.ResampleFilter.is_monkey_patched = True
QgsRasterPipe.ResampleFilter.__doc__ = ""
QgsRasterPipe.ResampleFilter.__doc__ = "Resampling occurs in ResamplingFilter"
QgsRasterPipe.Provider = Qgis.RasterResamplingStage.Provider
QgsRasterPipe.Provider.is_monkey_patched = True
QgsRasterPipe.Provider.__doc__ = ""
QgsRasterPipe.Provider.__doc__ = "Resampling occurs in Provider"
Qgis.RasterResamplingStage.__doc__ = """Stage at which raster resampling occurs.

.. versionadded:: 3.22

* ``ResampleFilter``:
* ``Provider``:
* ``ResampleFilter``: Resampling occurs in ResamplingFilter
* ``Provider``: Resampling occurs in Provider

"""
# --
Qgis.RasterResamplingStage.baseClass = Qgis
QgsRasterDataProvider.ResamplingMethod = Qgis.RasterResamplingMethod
# monkey patching scoped based enum
QgsRasterDataProvider.Nearest = Qgis.RasterResamplingMethod.Nearest
QgsRasterDataProvider.Nearest.is_monkey_patched = True
QgsRasterDataProvider.Nearest.__doc__ = "Nearest-neighbour resampling"
QgsRasterDataProvider.Bilinear = Qgis.RasterResamplingMethod.Bilinear
QgsRasterDataProvider.Bilinear.is_monkey_patched = True
QgsRasterDataProvider.Bilinear.__doc__ = "Bilinear (2x2 kernel) resampling"
QgsRasterDataProvider.Cubic = Qgis.RasterResamplingMethod.Cubic
QgsRasterDataProvider.Cubic.is_monkey_patched = True
QgsRasterDataProvider.Cubic.__doc__ = "Cubic Convolution Approximation (4x4 kernel) resampling"
QgsRasterDataProvider.CubicSpline = Qgis.RasterResamplingMethod.CubicSpline
QgsRasterDataProvider.CubicSpline.is_monkey_patched = True
QgsRasterDataProvider.CubicSpline.__doc__ = "Cubic B-Spline Approximation (4x4 kernel)"
QgsRasterDataProvider.Lanczos = Qgis.RasterResamplingMethod.Lanczos
QgsRasterDataProvider.Lanczos.is_monkey_patched = True
QgsRasterDataProvider.Lanczos.__doc__ = "Lanczos windowed sinc interpolation (6x6 kernel)"
QgsRasterDataProvider.Average = Qgis.RasterResamplingMethod.Average
QgsRasterDataProvider.Average.is_monkey_patched = True
QgsRasterDataProvider.Average.__doc__ = "Average resampling"
QgsRasterDataProvider.Mode = Qgis.RasterResamplingMethod.Mode
QgsRasterDataProvider.Mode.is_monkey_patched = True
QgsRasterDataProvider.Mode.__doc__ = "Mode (selects the value which appears most often of all the sampled points)"
QgsRasterDataProvider.Gauss = Qgis.RasterResamplingMethod.Gauss
QgsRasterDataProvider.Gauss.is_monkey_patched = True
QgsRasterDataProvider.Gauss.__doc__ = "Gauss blurring"
Qgis.RasterResamplingMethod.__doc__ = """Resampling method for raster provider-level resampling.

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterDataProvider`.ResamplingMethod

.. versionadded:: 3.42

* ``Nearest``: Nearest-neighbour resampling
* ``Bilinear``: Bilinear (2x2 kernel) resampling
* ``Cubic``: Cubic Convolution Approximation (4x4 kernel) resampling
* ``CubicSpline``: Cubic B-Spline Approximation (4x4 kernel)
* ``Lanczos``: Lanczos windowed sinc interpolation (6x6 kernel)
* ``Average``: Average resampling
* ``Mode``: Mode (selects the value which appears most often of all the sampled points)
* ``Gauss``: Gauss blurring

"""
# --
Qgis.RasterResamplingMethod.baseClass = Qgis
# monkey patching scoped based enum
Qgis.RasterRendererFlag.InternalLayerOpacityHandling.__doc__ = "The renderer internally handles the raster layer's opacity, so the default layer level opacity handling should not be applied."
Qgis.RasterRendererFlag.UseNoDataForOutOfRangePixels.__doc__ = "Out of range pixels (eg those values outside of the rendered map's z range filter) should be set using additional nodata values instead of additional transparency values \n.. versionadded:: 3.38"
Expand Down
24 changes: 0 additions & 24 deletions python/core/auto_additions/qgsrasterdataprovider.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
# The following has been generated automatically from src/core/raster/qgsrasterdataprovider.h
# monkey patching scoped based enum
QgsRasterDataProvider.ResamplingMethod.Nearest.__doc__ = "Nearest-neighbour resampling"
QgsRasterDataProvider.ResamplingMethod.Bilinear.__doc__ = "Bilinear (2x2 kernel) resampling"
QgsRasterDataProvider.ResamplingMethod.Cubic.__doc__ = "Cubic Convolution Approximation (4x4 kernel) resampling"
QgsRasterDataProvider.ResamplingMethod.CubicSpline.__doc__ = "Cubic B-Spline Approximation (4x4 kernel)"
QgsRasterDataProvider.ResamplingMethod.Lanczos.__doc__ = "Lanczos windowed sinc interpolation (6x6 kernel)"
QgsRasterDataProvider.ResamplingMethod.Average.__doc__ = "Average resampling"
QgsRasterDataProvider.ResamplingMethod.Mode.__doc__ = "Mode (selects the value which appears most often of all the sampled points)"
QgsRasterDataProvider.ResamplingMethod.Gauss.__doc__ = "Gauss blurring"
QgsRasterDataProvider.ResamplingMethod.__doc__ = """Resampling method for provider-level resampling.
.. versionadded:: 3.16
* ``Nearest``: Nearest-neighbour resampling
* ``Bilinear``: Bilinear (2x2 kernel) resampling
* ``Cubic``: Cubic Convolution Approximation (4x4 kernel) resampling
* ``CubicSpline``: Cubic B-Spline Approximation (4x4 kernel)
* ``Lanczos``: Lanczos windowed sinc interpolation (6x6 kernel)
* ``Average``: Average resampling
* ``Mode``: Mode (selects the value which appears most often of all the sampled points)
* ``Gauss``: Gauss blurring
"""
# --
try:
QgsImageFetcher.__attribute_docs__ = {'finish': 'Emitted when the download completes\n\n:param legend: The downloaded legend image\n', 'progress': 'Emitted to report progress\n', 'error': 'Emitted when an error occurs\n'}
QgsImageFetcher.__signal_arguments__ = {'finish': ['legend: QImage'], 'progress': ['received: int', 'total: int'], 'error': ['msg: str']}
Expand Down
16 changes: 13 additions & 3 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,20 @@ The development version

enum class RasterResamplingStage
{
//! Resampling occurs in ResamplingFilter
ResampleFilter,
//! Resampling occurs in Provider
Provider
Provider,
};

enum class RasterResamplingMethod
{
Nearest,
Bilinear,
Cubic,
CubicSpline,
Lanczos,
Average,
Mode,
Gauss
};

enum class RasterRendererFlag
Expand Down
20 changes: 4 additions & 16 deletions python/core/auto_generated/raster/qgsrasterdataprovider.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -627,19 +627,7 @@ Returns whether provider-level resampling is enabled.
.. versionadded:: 3.16
%End

enum class ResamplingMethod
{
Nearest,
Bilinear,
Cubic,
CubicSpline,
Lanczos,
Average,
Mode,
Gauss
};

virtual bool setZoomedInResamplingMethod( ResamplingMethod method );
virtual bool setZoomedInResamplingMethod( Qgis::RasterResamplingMethod method );
%Docstring
Set resampling method to apply for zoomed-in operations.

Expand All @@ -648,14 +636,14 @@ Set resampling method to apply for zoomed-in operations.
.. versionadded:: 3.16
%End

ResamplingMethod zoomedInResamplingMethod() const;
Qgis::RasterResamplingMethod zoomedInResamplingMethod() const;
%Docstring
Returns resampling method for zoomed-in operations.

.. versionadded:: 3.16
%End

virtual bool setZoomedOutResamplingMethod( ResamplingMethod method );
virtual bool setZoomedOutResamplingMethod( Qgis::RasterResamplingMethod method );
%Docstring
Set resampling method to apply for zoomed-out operations.

Expand All @@ -664,7 +652,7 @@ Set resampling method to apply for zoomed-out operations.
.. versionadded:: 3.16
%End

ResamplingMethod zoomedOutResamplingMethod() const;
Qgis::RasterResamplingMethod zoomedOutResamplingMethod() const;
%Docstring
Returns resampling method for zoomed-out operations.

Expand Down
Loading

0 comments on commit c607dad

Please sign in to comment.