Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move QgsRasterMinMaxOrigin enums to Qgis, promote to enum class #59644

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,100 @@
Qgis.RasterRendererCapabilities = lambda flags=0: Qgis.RasterRendererCapability(flags)
Qgis.RasterRendererCapabilities.baseClass = Qgis
RasterRendererCapabilities = Qgis # dirty hack since SIP seems to introduce the flags in module
QgsRasterMinMaxOrigin.Limits = Qgis.RasterRangeLimit
# monkey patching scoped based enum
QgsRasterMinMaxOrigin.None_ = Qgis.RasterRangeLimit.NotSet
QgsRasterMinMaxOrigin.Limits.None_ = Qgis.RasterRangeLimit.NotSet
QgsRasterMinMaxOrigin.None_.is_monkey_patched = True
QgsRasterMinMaxOrigin.None_.__doc__ = "User defined"
QgsRasterMinMaxOrigin.MinMax = Qgis.RasterRangeLimit.MinimumMaximum
QgsRasterMinMaxOrigin.Limits.MinMax = Qgis.RasterRangeLimit.MinimumMaximum
QgsRasterMinMaxOrigin.MinMax.is_monkey_patched = True
QgsRasterMinMaxOrigin.MinMax.__doc__ = "Real min-max values"
QgsRasterMinMaxOrigin.StdDev = Qgis.RasterRangeLimit.StdDev
QgsRasterMinMaxOrigin.StdDev.is_monkey_patched = True
QgsRasterMinMaxOrigin.StdDev.__doc__ = "Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ]"
QgsRasterMinMaxOrigin.CumulativeCut = Qgis.RasterRangeLimit.CumulativeCut
QgsRasterMinMaxOrigin.CumulativeCut.is_monkey_patched = True
QgsRasterMinMaxOrigin.CumulativeCut.__doc__ = "Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]"
Qgis.RasterRangeLimit.__doc__ = """Describes the limits used to compute raster ranges (min/max values).

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterMinMaxOrigin`.Limits

.. versionadded:: 3.42

* ``NotSet``: User defined

Available as ``QgsRasterMinMaxOrigin.None_`` in older QGIS releases.

* ``MinimumMaximum``: Real min-max values

Available as ``QgsRasterMinMaxOrigin.MinMax`` in older QGIS releases.

* ``StdDev``: Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ]
* ``CumulativeCut``: Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]

"""
# --
Qgis.RasterRangeLimit.baseClass = Qgis
QgsRasterMinMaxOrigin.Extent = Qgis.RasterRangeExtent
# monkey patching scoped based enum
QgsRasterMinMaxOrigin.None_ = Qgis.RasterRangeExtent.WholeRaster
QgsRasterMinMaxOrigin.Extent.None_ = Qgis.RasterRangeExtent.WholeRaster
QgsRasterMinMaxOrigin.None_.is_monkey_patched = True
QgsRasterMinMaxOrigin.None_.__doc__ = "Whole raster is used to compute statistics"
QgsRasterMinMaxOrigin.CurrentCanvas = Qgis.RasterRangeExtent.FixedCanvas
QgsRasterMinMaxOrigin.Extent.CurrentCanvas = Qgis.RasterRangeExtent.FixedCanvas
QgsRasterMinMaxOrigin.CurrentCanvas.is_monkey_patched = True
QgsRasterMinMaxOrigin.CurrentCanvas.__doc__ = "Current extent of the canvas (at the time of computation) is used to compute statistics"
QgsRasterMinMaxOrigin.UpdatedCanvas = Qgis.RasterRangeExtent.UpdatedCanvas
QgsRasterMinMaxOrigin.UpdatedCanvas.is_monkey_patched = True
QgsRasterMinMaxOrigin.UpdatedCanvas.__doc__ = "Constantly updated extent of the canvas is used to compute statistics"
Qgis.RasterRangeExtent.__doc__ = """Describes the extent used to compute raster ranges (min/max values).

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterMinMaxOrigin`.Extent

.. versionadded:: 3.42

* ``WholeRaster``: Whole raster is used to compute statistics

Available as ``QgsRasterMinMaxOrigin.None_`` in older QGIS releases.

* ``FixedCanvas``: Current extent of the canvas (at the time of computation) is used to compute statistics

Available as ``QgsRasterMinMaxOrigin.CurrentCanvas`` in older QGIS releases.

* ``UpdatedCanvas``: Constantly updated extent of the canvas is used to compute statistics

"""
# --
Qgis.RasterRangeExtent.baseClass = Qgis
QgsRasterMinMaxOrigin.StatAccuracy = Qgis.RasterRangeAccuracy
# monkey patching scoped based enum
QgsRasterMinMaxOrigin.Exact = Qgis.RasterRangeAccuracy.Exact
QgsRasterMinMaxOrigin.Exact.is_monkey_patched = True
QgsRasterMinMaxOrigin.Exact.__doc__ = "Exact statistics"
QgsRasterMinMaxOrigin.Estimated = Qgis.RasterRangeAccuracy.Estimated
QgsRasterMinMaxOrigin.Estimated.is_monkey_patched = True
QgsRasterMinMaxOrigin.Estimated.__doc__ = "Approximated statistics"
Qgis.RasterRangeAccuracy.__doc__ = """Describes the accuracy used to compute raster ranges (min/max values).

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterMinMaxOrigin`.StatAccuracy

.. versionadded:: 3.42

* ``Exact``: Exact statistics
* ``Estimated``: Approximated statistics

"""
# --
Qgis.RasterRangeAccuracy.baseClass = Qgis
# monkey patching scoped based enum
Qgis.RasterAttributeTableFieldUsage.Generic.__doc__ = "Field usage Generic"
Qgis.RasterAttributeTableFieldUsage.PixelCount.__doc__ = "Field usage PixelCount"
Expand Down
9 changes: 0 additions & 9 deletions python/PyQt6/core/auto_additions/qgsrasterminmaxorigin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
# The following has been generated automatically from src/core/raster/qgsrasterminmaxorigin.h
QgsRasterMinMaxOrigin.None_ = QgsRasterMinMaxOrigin.Limits.None_
QgsRasterMinMaxOrigin.MinMax = QgsRasterMinMaxOrigin.Limits.MinMax
QgsRasterMinMaxOrigin.StdDev = QgsRasterMinMaxOrigin.Limits.StdDev
QgsRasterMinMaxOrigin.CumulativeCut = QgsRasterMinMaxOrigin.Limits.CumulativeCut
QgsRasterMinMaxOrigin.WholeRaster = QgsRasterMinMaxOrigin.Extent.WholeRaster
QgsRasterMinMaxOrigin.CurrentCanvas = QgsRasterMinMaxOrigin.Extent.CurrentCanvas
QgsRasterMinMaxOrigin.UpdatedCanvas = QgsRasterMinMaxOrigin.Extent.UpdatedCanvas
QgsRasterMinMaxOrigin.Exact = QgsRasterMinMaxOrigin.StatAccuracy.Exact
QgsRasterMinMaxOrigin.Estimated = QgsRasterMinMaxOrigin.StatAccuracy.Estimated
try:
QgsRasterMinMaxOrigin.__attribute_docs__ = {'CUMULATIVE_CUT_LOWER': 'Default cumulative cut lower limit', 'CUMULATIVE_CUT_UPPER': 'Default cumulative cut upper limit', 'DEFAULT_STDDEV_FACTOR': 'Default standard deviation factor'}
QgsRasterMinMaxOrigin.limitsString = staticmethod(QgsRasterMinMaxOrigin.limitsString)
Expand Down
21 changes: 21 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,27 @@ The development version
typedef QFlags<Qgis::RasterRendererCapability> RasterRendererCapabilities;


enum class RasterRangeLimit /BaseType=IntEnum/
{
NotSet,
MinimumMaximum,
StdDev,
CumulativeCut
};

enum class RasterRangeExtent /BaseType=IntEnum/
{
WholeRaster,
FixedCanvas,
UpdatedCanvas,
};

enum class RasterRangeAccuracy /BaseType=IntEnum/
{
Exact,
Estimated,
};

enum class RasterAttributeTableFieldUsage /BaseType=IntEnum/
{
Generic,
Expand Down
8 changes: 4 additions & 4 deletions python/PyQt6/core/auto_generated/raster/qgsrasterlayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Sample usage of the :py:class:`QgsRasterLayer` class:

static const QgsContrastEnhancement::ContrastEnhancementAlgorithm MULTIPLE_BAND_MULTI_BYTE_ENHANCEMENT_ALGORITHM;

static const QgsRasterMinMaxOrigin::Limits SINGLE_BAND_MIN_MAX_LIMITS;
static const Qgis::RasterRangeLimit SINGLE_BAND_MIN_MAX_LIMITS;

static const QgsRasterMinMaxOrigin::Limits MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS;
static const Qgis::RasterRangeLimit MULTIPLE_BAND_SINGLE_BYTE_MIN_MAX_LIMITS;

static const QgsRasterMinMaxOrigin::Limits MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS;
static const Qgis::RasterRangeLimit MULTIPLE_BAND_MULTI_BYTE_MIN_MAX_LIMITS;

QgsRasterLayer();
%Docstring
Expand Down Expand Up @@ -339,7 +339,7 @@ In a world file, this is normally the first row (without the sign).


void setContrastEnhancement( QgsContrastEnhancement::ContrastEnhancementAlgorithm algorithm,
QgsRasterMinMaxOrigin::Limits limits = QgsRasterMinMaxOrigin::MinMax,
Qgis::RasterRangeLimit limits = Qgis::RasterRangeLimit::MinimumMaximum,
const QgsRectangle &extent = QgsRectangle(),
int sampleSize = QgsRasterLayer::SAMPLE_SIZE,
bool generateLookupTableFlag = true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,22 @@ itself the min/max values.

static const double DEFAULT_STDDEV_FACTOR;

//! \brief This enumerator describes the limits used to compute min/max values
enum Limits /BaseType=IntEnum/
{
None /PyName=None_/,
MinMax,
StdDev,
CumulativeCut
};

enum Extent /BaseType=IntEnum/
{
//! Whole raster is used to compute statistics.
WholeRaster,
//! Current extent of the canvas (at the time of computation) is used to compute statistics.
CurrentCanvas,
//! Constantly updated extent of the canvas is used to compute statistics.
UpdatedCanvas
};

enum StatAccuracy /BaseType=IntEnum/
{
//! Exact statistics.
Exact,
//! Approximated statistics.
Estimated
};

QgsRasterMinMaxOrigin();

bool operator ==( const QgsRasterMinMaxOrigin &other ) const;


QgsRasterMinMaxOrigin::Limits limits() const;
Qgis::RasterRangeLimit limits() const;
%Docstring
Returns the raster limits.
%End

QgsRasterMinMaxOrigin::Extent extent() const;
Qgis::RasterRangeExtent extent() const;
%Docstring
Returns the raster extent.
%End

QgsRasterMinMaxOrigin::StatAccuracy statAccuracy() const;
Qgis::RasterRangeAccuracy statAccuracy() const;
%Docstring
Returns the raster statistic accuracy.
%End
Expand All @@ -91,17 +64,17 @@ Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f
%End


void setLimits( QgsRasterMinMaxOrigin::Limits limits );
void setLimits( Qgis::RasterRangeLimit limits );
%Docstring
Sets the limits.
%End

void setExtent( QgsRasterMinMaxOrigin::Extent extent );
void setExtent( Qgis::RasterRangeExtent extent );
%Docstring
Sets the extent.
%End

void setStatAccuracy( QgsRasterMinMaxOrigin::StatAccuracy accuracy );
void setStatAccuracy( Qgis::RasterRangeAccuracy accuracy );
%Docstring
Sets the statistics accuracy.
%End
Expand Down Expand Up @@ -133,32 +106,32 @@ Deserialize object.
%End


static QString limitsString( Limits limits );
static QString limitsString( Qgis::RasterRangeLimit limits );
%Docstring
Returns a string to serialize Limits
%End

static Limits limitsFromString( const QString &limits );
static Qgis::RasterRangeLimit limitsFromString( const QString &limits );
%Docstring
Deserialize Limits
%End

static QString extentString( QgsRasterMinMaxOrigin::Extent extent );
static QString extentString( Qgis::RasterRangeExtent extent );
%Docstring
Returns a string to serialize Extent
%End

static QgsRasterMinMaxOrigin::Extent extentFromString( const QString &extent );
static Qgis::RasterRangeExtent extentFromString( const QString &extent );
%Docstring
Deserialize Extent
%End

static QString statAccuracyString( QgsRasterMinMaxOrigin::StatAccuracy accuracy );
static QString statAccuracyString( Qgis::RasterRangeAccuracy accuracy );
%Docstring
Returns a string to serialize StatAccuracy
%End

static QgsRasterMinMaxOrigin::StatAccuracy statAccuracyFromString( const QString &accuracy );
static Qgis::RasterRangeAccuracy statAccuracyFromString( const QString &accuracy );
%Docstring
Deserialize StatAccuracy
%End
Expand Down
94 changes: 94 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,100 @@
Qgis.RasterRendererCapability.baseClass = Qgis
Qgis.RasterRendererCapabilities.baseClass = Qgis
RasterRendererCapabilities = Qgis # dirty hack since SIP seems to introduce the flags in module
QgsRasterMinMaxOrigin.Limits = Qgis.RasterRangeLimit
# monkey patching scoped based enum
QgsRasterMinMaxOrigin.None_ = Qgis.RasterRangeLimit.NotSet
QgsRasterMinMaxOrigin.Limits.None_ = Qgis.RasterRangeLimit.NotSet
QgsRasterMinMaxOrigin.None_.is_monkey_patched = True
QgsRasterMinMaxOrigin.None_.__doc__ = "User defined"
QgsRasterMinMaxOrigin.MinMax = Qgis.RasterRangeLimit.MinimumMaximum
QgsRasterMinMaxOrigin.Limits.MinMax = Qgis.RasterRangeLimit.MinimumMaximum
QgsRasterMinMaxOrigin.MinMax.is_monkey_patched = True
QgsRasterMinMaxOrigin.MinMax.__doc__ = "Real min-max values"
QgsRasterMinMaxOrigin.StdDev = Qgis.RasterRangeLimit.StdDev
QgsRasterMinMaxOrigin.StdDev.is_monkey_patched = True
QgsRasterMinMaxOrigin.StdDev.__doc__ = "Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ]"
QgsRasterMinMaxOrigin.CumulativeCut = Qgis.RasterRangeLimit.CumulativeCut
QgsRasterMinMaxOrigin.CumulativeCut.is_monkey_patched = True
QgsRasterMinMaxOrigin.CumulativeCut.__doc__ = "Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]"
Qgis.RasterRangeLimit.__doc__ = """Describes the limits used to compute raster ranges (min/max values).

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterMinMaxOrigin`.Limits

.. versionadded:: 3.42

* ``NotSet``: User defined

Available as ``QgsRasterMinMaxOrigin.None_`` in older QGIS releases.

* ``MinimumMaximum``: Real min-max values

Available as ``QgsRasterMinMaxOrigin.MinMax`` in older QGIS releases.

* ``StdDev``: Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ]
* ``CumulativeCut``: Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ]

"""
# --
Qgis.RasterRangeLimit.baseClass = Qgis
QgsRasterMinMaxOrigin.Extent = Qgis.RasterRangeExtent
# monkey patching scoped based enum
QgsRasterMinMaxOrigin.None_ = Qgis.RasterRangeExtent.WholeRaster
QgsRasterMinMaxOrigin.Extent.None_ = Qgis.RasterRangeExtent.WholeRaster
QgsRasterMinMaxOrigin.None_.is_monkey_patched = True
QgsRasterMinMaxOrigin.None_.__doc__ = "Whole raster is used to compute statistics"
QgsRasterMinMaxOrigin.CurrentCanvas = Qgis.RasterRangeExtent.FixedCanvas
QgsRasterMinMaxOrigin.Extent.CurrentCanvas = Qgis.RasterRangeExtent.FixedCanvas
QgsRasterMinMaxOrigin.CurrentCanvas.is_monkey_patched = True
QgsRasterMinMaxOrigin.CurrentCanvas.__doc__ = "Current extent of the canvas (at the time of computation) is used to compute statistics"
QgsRasterMinMaxOrigin.UpdatedCanvas = Qgis.RasterRangeExtent.UpdatedCanvas
QgsRasterMinMaxOrigin.UpdatedCanvas.is_monkey_patched = True
QgsRasterMinMaxOrigin.UpdatedCanvas.__doc__ = "Constantly updated extent of the canvas is used to compute statistics"
Qgis.RasterRangeExtent.__doc__ = """Describes the extent used to compute raster ranges (min/max values).

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterMinMaxOrigin`.Extent

.. versionadded:: 3.42

* ``WholeRaster``: Whole raster is used to compute statistics

Available as ``QgsRasterMinMaxOrigin.None_`` in older QGIS releases.

* ``FixedCanvas``: Current extent of the canvas (at the time of computation) is used to compute statistics

Available as ``QgsRasterMinMaxOrigin.CurrentCanvas`` in older QGIS releases.

* ``UpdatedCanvas``: Constantly updated extent of the canvas is used to compute statistics

"""
# --
Qgis.RasterRangeExtent.baseClass = Qgis
QgsRasterMinMaxOrigin.StatAccuracy = Qgis.RasterRangeAccuracy
# monkey patching scoped based enum
QgsRasterMinMaxOrigin.Exact = Qgis.RasterRangeAccuracy.Exact
QgsRasterMinMaxOrigin.Exact.is_monkey_patched = True
QgsRasterMinMaxOrigin.Exact.__doc__ = "Exact statistics"
QgsRasterMinMaxOrigin.Estimated = Qgis.RasterRangeAccuracy.Estimated
QgsRasterMinMaxOrigin.Estimated.is_monkey_patched = True
QgsRasterMinMaxOrigin.Estimated.__doc__ = "Approximated statistics"
Qgis.RasterRangeAccuracy.__doc__ = """Describes the accuracy used to compute raster ranges (min/max values).

.. note::

Prior to QGIS 3.42 this was available as :py:class:`QgsRasterMinMaxOrigin`.StatAccuracy

.. versionadded:: 3.42

* ``Exact``: Exact statistics
* ``Estimated``: Approximated statistics

"""
# --
Qgis.RasterRangeAccuracy.baseClass = Qgis
# monkey patching scoped based enum
Qgis.RasterAttributeTableFieldUsage.Generic.__doc__ = "Field usage Generic"
Qgis.RasterAttributeTableFieldUsage.PixelCount.__doc__ = "Field usage PixelCount"
Expand Down
Loading
Loading