31using namespace Qt::StringLiterals;
75 QList< int > temporalBands;
76 switch ( temporalProperties->
mode() )
90 temporalBands << temporalProperties->
bandNumber();
95 if ( temporalBands.empty() )
101 switch ( elevationProperties->
mode() )
105 return temporalBands.at( 0 );
110 int currentMatchingBand = -1;
113 const QMap<int, QgsDoubleRange> rangePerBand = elevationProperties->
fixedRangePerBand();
114 for (
int band : temporalBands )
117 if ( rangeForBand.
overlaps( elevationRange ) )
124 currentMatchingBand = band;
125 currentMatchingRange = rangeForBand;
129 return currentMatchingBand;
141 lowerProperty.
prepare( context );
142 upperProperty.
prepare( context );
144 int currentMatchingBand = -1;
148 for (
int band : temporalBands )
155 const double lower = lowerProperty.
valueAsDouble( context, 0, &ok );
158 const double upper = upperProperty.
valueAsDouble( context, 0, &ok );
163 if ( bandRange.
overlaps( elevationRange ) )
169 currentMatchingBand = band;
170 currentMatchingRange = bandRange;
175 return currentMatchingBand;
190 min = std::numeric_limits<double>::quiet_NaN();
191 max = std::numeric_limits<double>::quiet_NaN();
205 switch ( provider->
dataType( band ) )
215 myRasterBandStats.
minimumValue = std::numeric_limits<int8_t>::lowest();
216 myRasterBandStats.
maximumValue = std::numeric_limits<int8_t>::max();
222 myRasterBandStats.
maximumValue = std::numeric_limits<uint16_t>::max();
228 myRasterBandStats.
maximumValue = std::numeric_limits<uint32_t>::max();
234 myRasterBandStats.
minimumValue = std::numeric_limits<int16_t>::lowest();
235 myRasterBandStats.
maximumValue = std::numeric_limits<int16_t>::max();
241 myRasterBandStats.
minimumValue = std::numeric_limits<int32_t>::lowest();
242 myRasterBandStats.
maximumValue = std::numeric_limits<int32_t>::max();
248 myRasterBandStats.
minimumValue = std::numeric_limits<float_t>::lowest();
249 myRasterBandStats.
maximumValue = std::numeric_limits<float_t>::max();
255 myRasterBandStats.
minimumValue = std::numeric_limits<double_t>::lowest();
256 myRasterBandStats.
maximumValue = std::numeric_limits<double_t>::max();
281 QgsDebugMsgLevel( u
"myLower = %1 myUpper = %2"_s.arg( myLower ).arg( myUpper ), 4 );
282 provider->
cumulativeCut( band, myLower, myUpper, min, max, extent, sampleSize );
284 QgsDebugMsgLevel( u
"band = %1 min = %2 max = %3"_s.arg( band ).arg( min ).arg( max ), 4 );
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.
@ FixedRangePerBand
Layer has a fixed (manually specified) elevation range per band.
@ FixedElevationRange
Layer has a fixed elevation range.
@ RepresentsElevationSurface
Pixel values represent an elevation surface.
@ DynamicRangePerBand
Layer has a elevation range per band, calculated dynamically from an expression.
@ RepresentsTemporalValues
Pixel values represent an datetime.
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
@ FixedRangePerBand
Layer has a fixed temporal range per band.
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
@ FixedDateTime
Layer has a fixed date time instant.
@ StdDev
Standard deviation.
@ NoStatistic
No statistic.
@ Float32
Thirty two bit floating point (float).
@ CFloat64
Complex Float64.
@ Int16
Sixteen bit signed integer (qint16).
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30).
@ UInt16
Sixteen bit unsigned integer (quint16).
@ Byte
Eight bit unsigned integer (quint8).
@ UnknownDataType
Unknown or unspecified type.
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
@ Int32
Thirty two bit signed integer (qint32).
@ Float64
Sixty four bit floating point (double).
@ CFloat32
Complex Float32.
@ UInt32
Thirty two bit unsigned integer (quint32).
QgsRange which stores a range of double values.
bool isInfinite() const
Returns true if the range consists of all possible values.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the object's property collection, used for data defined overrides.
@ RasterPerBandUpperElevation
Upper elevation for each raster band.
@ RasterPerBandLowerElevation
Lower elevation for each raster band.
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
A store for object properties.
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const
Prepares the property against a specified expression context.
bool includeUpper() const
Returns true if the upper bound is inclusive, or false if the upper bound is exclusive.
bool overlaps(const QgsRange< T > &other) const
Returns true if this range overlaps another range.
T upper() const
Returns the upper bound of the range.
The RasterBandStats struct is a container for statistics about a single raster band.
double mean
The mean cell value for the band. NO_DATA values are excluded.
double stdDev
The standard deviation of the cell values.
double minimumValue
The minimum cell value in the raster band.
Qgis::RasterBandStatistics statsGathered
Collected statistics.
double maximumValue
The maximum cell value in the raster band.
Base class for raster data providers.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
virtual QString bandDescription(int bandNumber)
Returns the description for band bandNumber, or an empty string if the band is not valid or has not d...
virtual void cumulativeCut(int bandNo, double lowerCount, double upperCount, double &lowerValue, double &upperValue, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
Find values for cumulative pixel count cut.
Q_DECL_DEPRECATED QgsRasterBandStats bandStatistics(int bandNo, int stats, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
QString displayBandName(int bandNumber) const
Generates a friendly, descriptive name for the specified bandNumber.
Raster layer specific subclass of QgsMapLayerElevationProperties.
Qgis::RasterElevationMode mode() const
Returns the elevation mode.
bool hasElevation() const override
Returns true if the layer has an elevation or z component.
int bandForElevationRange(QgsRasterLayer *layer, const QgsDoubleRange &range) const
Returns the band corresponding to the specified range.
QMap< int, QgsDoubleRange > fixedRangePerBand() const
Returns the fixed elevation range for each band.
Implementation of map layer temporal properties for raster layers.
QList< int > filteredBandsForTemporalRange(QgsRasterLayer *layer, const QgsDateTimeRange &range) const
Returns a filtered list of bands which match the specified range.
Qgis::RasterTemporalMode mode() const
Returns the temporal properties mode.
int bandForTemporalRange(QgsRasterLayer *layer, const QgsDateTimeRange &range) const
Returns the band corresponding to the specified range.
int bandNumber() const
Returns the band number from which temporal values should be taken.
static void computeMinMax(QgsRasterDataProvider *provider, int band, const QgsRasterMinMaxOrigin &mmo, Qgis::RasterRangeLimit limits, const QgsRectangle &extent, int sampleSize, double &min, double &max)
Compute the min max values for provider along band according to MinMaxOrigin parameters mmo and exten...
static int renderedBandForElevationAndTemporalRange(QgsRasterLayer *layer, const QgsDateTimeRange &temporalRange, const QgsDoubleRange &elevationRange, bool &matched)
Given a raster layer, returns the band which should be used for rendering the layer for a specified t...
Represents a raster layer.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
Describes the origin of minimum and maximum values in a raster.
double cumulativeCutLower() const
Returns the lower bound of cumulative cut method (between 0 and 1).
double stdDevFactor() const
Returns the factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ].
double cumulativeCutUpper() const
Returns the upper bound of cumulative cut method (between 0 and 1).
A rectangle specified with double values.
bool isActive() const
Returns true if the temporal property is active.
bool isInfinite() const
Returns true if the range consists of all possible values.
#define BUILTIN_UNREACHABLE
#define QgsDebugMsgLevel(str, level)
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
#define QGIS_CHECK_OTHER_QOBJECT_THREAD_ACCESS(other)