21#include <QDomDocument>
26 : mCumulativeCutLower( CUMULATIVE_CUT_LOWER )
27 , mCumulativeCutUpper( CUMULATIVE_CUT_UPPER )
28 , mStdDevFactor( DEFAULT_STDDEV_FACTOR )
38 return mLimits == other.mLimits &&
39 mExtent == other.mExtent &&
40 mAccuracy == other.mAccuracy &&
41 std::fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 &&
42 std::fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 &&
43 std::fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5;
51 return QStringLiteral(
"MinMax" );
53 return QStringLiteral(
"StdDev" );
55 return QStringLiteral(
"CumulativeCut" );
59 return QStringLiteral(
"None" );
64 if (
limits == QLatin1String(
"MinMax" ) )
68 else if (
limits == QLatin1String(
"StdDev" ) )
72 else if (
limits == QLatin1String(
"CumulativeCut" ) )
81 switch ( minMaxExtent )
84 return QStringLiteral(
"WholeRaster" );
86 return QStringLiteral(
"CurrentCanvas" );
88 return QStringLiteral(
"UpdatedCanvas" );
90 return QStringLiteral(
"WholeRaster" );
95 if (
extent == QLatin1String(
"WholeRaster" ) )
99 else if (
extent == QLatin1String(
"CurrentCanvas" ) )
103 else if (
extent == QLatin1String(
"UpdatedCanvas" ) )
118 return QStringLiteral(
"Exact" );
120 return QStringLiteral(
"Estimated" );
127 if ( accuracy == QLatin1String(
"Exact" ) )
135 QDomElement limitsElem = doc.createElement( QStringLiteral(
"limits" ) );
136 const QDomText limitsText = doc.createTextNode(
limitsString( mLimits ) );
137 limitsElem.appendChild( limitsText );
138 parentElem.appendChild( limitsElem );
141 QDomElement extentElem = doc.createElement( QStringLiteral(
"extent" ) );
142 const QDomText extentText = doc.createTextNode(
extentString( mExtent ) );
143 extentElem.appendChild( extentText );
144 parentElem.appendChild( extentElem );
147 QDomElement statAccuracyElem = doc.createElement( QStringLiteral(
"statAccuracy" ) );
148 const QDomText statAccuracyText = doc.createTextNode(
statAccuracyString( mAccuracy ) );
149 statAccuracyElem.appendChild( statAccuracyText );
150 parentElem.appendChild( statAccuracyElem );
153 QDomElement cumulativeCutLowerElem = doc.createElement( QStringLiteral(
"cumulativeCutLower" ) );
154 const QDomText cumulativeCutLowerText = doc.createTextNode( QString::number( mCumulativeCutLower ) );
155 cumulativeCutLowerElem.appendChild( cumulativeCutLowerText );
156 parentElem.appendChild( cumulativeCutLowerElem );
159 QDomElement cumulativeCutUpperElem = doc.createElement( QStringLiteral(
"cumulativeCutUpper" ) );
160 const QDomText cumulativeCutUpperText = doc.createTextNode( QString::number( mCumulativeCutUpper ) );
161 cumulativeCutUpperElem.appendChild( cumulativeCutUpperText );
162 parentElem.appendChild( cumulativeCutUpperElem );
165 QDomElement stdDevFactorElem = doc.createElement( QStringLiteral(
"stdDevFactor" ) );
166 const QDomText stdDevFactorText = doc.createTextNode( QString::number( mStdDevFactor ) );
167 stdDevFactorElem.appendChild( stdDevFactorText );
168 parentElem.appendChild( stdDevFactorElem );
173 const QDomElement limitsElem = elem.firstChildElement( QStringLiteral(
"limits" ) );
174 if ( !limitsElem.isNull() )
179 const QDomElement extentElem = elem.firstChildElement( QStringLiteral(
"extent" ) );
180 if ( !extentElem.isNull() )
185 const QDomElement statAccuracyElem = elem.firstChildElement( QStringLiteral(
"statAccuracy" ) );
186 if ( !statAccuracyElem.isNull() )
191 const QDomElement cumulativeCutLowerElem = elem.firstChildElement( QStringLiteral(
"cumulativeCutLower" ) );
192 if ( !cumulativeCutLowerElem.isNull() )
194 mCumulativeCutLower = cumulativeCutLowerElem.text().toDouble();
197 const QDomElement cumulativeCutUpperElem = elem.firstChildElement( QStringLiteral(
"cumulativeCutUpper" ) );
198 if ( !cumulativeCutUpperElem.isNull() )
200 mCumulativeCutUpper = cumulativeCutUpperElem.text().toDouble();
203 const QDomElement stdDevFactorElem = elem.firstChildElement( QStringLiteral(
"stdDevFactor" ) );
204 if ( !stdDevFactorElem.isNull() )
206 mStdDevFactor = stdDevFactorElem.text().toDouble();
RasterRangeLimit
Describes the limits used to compute raster ranges (min/max values).
@ CumulativeCut
Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ].
@ StdDev
Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ].
@ MinimumMaximum
Real min-max values.
RasterRangeAccuracy
Describes the accuracy used to compute raster ranges (min/max values).
@ Estimated
Approximated statistics.
RasterRangeExtent
Describes the extent used to compute raster ranges (min/max values).
@ UpdatedCanvas
Constantly updated extent of the canvas is used to compute statistics.
@ WholeRaster
Whole raster is used to compute statistics.
@ FixedCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
This class describes the origin of min/max values.
static QString limitsString(Qgis::RasterRangeLimit limits)
Returns a string to serialize Limits.
Qgis::RasterRangeExtent extent() const
Returns the raster extent.
static Qgis::RasterRangeAccuracy statAccuracyFromString(const QString &accuracy)
Deserialize StatAccuracy.
static constexpr double CUMULATIVE_CUT_UPPER
Default cumulative cut upper limit.
static QString statAccuracyString(Qgis::RasterRangeAccuracy accuracy)
Returns a string to serialize StatAccuracy.
static constexpr double DEFAULT_STDDEV_FACTOR
Default standard deviation factor.
static QString extentString(Qgis::RasterRangeExtent extent)
Returns a string to serialize Extent.
bool operator==(const QgsRasterMinMaxOrigin &other) const
static constexpr double CUMULATIVE_CUT_LOWER
Default cumulative cut lower limit.
void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Serialize object.
void readXml(const QDomElement &elem)
Deserialize object.
static Qgis::RasterRangeLimit limitsFromString(const QString &limits)
Deserialize Limits.
Qgis::RasterRangeLimit limits() const
Returns the raster limits.
static Qgis::RasterRangeExtent extentFromString(const QString &extent)
Deserialize Extent.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
#define BUILTIN_UNREACHABLE