QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsrenderedlayerstatistics.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrenderedlayerstatistics.h
3 ----------------
4 copyright : (C) 2024 by Jean Felder
5 email : jean dot felder at oslandia dot com
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSRENDEREDLAYERSTATISTICS_H
18#define QGSRENDEREDLAYERSTATISTICS_H
19
20#include <limits>
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
36{
37 public:
38
46 QgsRenderedLayerStatistics( const QString &layerId, const QList<double> &minimum, const QList<double> &maximum );
47
51#ifndef SIP_RUN
52 QgsRenderedLayerStatistics( const QString &layerId, double minimum = std::numeric_limits<double>::quiet_NaN(), double maximum = std::numeric_limits<double>::quiet_NaN() );
53#else
54 QgsRenderedLayerStatistics( const QString &layerId, SIP_PYOBJECT minimum SIP_TYPEHINT( Optional[float] ) = Py_None, SIP_PYOBJECT maximum SIP_TYPEHINT( Optional[float] ) = Py_None ) [( const QString & layerId, double minimum = 0.0, double maximum = 0.0 )];
55 % MethodCode
56 double minP = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
57 double maxP = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
58 QList<double> minL = {minP};
59 QList<double> maxL = {maxP};
60 sipCpp = new sipQgsRenderedLayerStatistics( *a0, minL, maxL );
61 % End
62#endif
63
64#ifdef SIP_RUN
65 SIP_PYOBJECT __repr__();
66 % MethodCode
67 QStringList minimums;
68 minimums.reserve( sipCpp->minimum().size() );
69 for ( double min : sipCpp->minimum() )
70 {
71 minimums.append( QString::number( min ) );
72 }
73 QStringList maximums;
74 maximums.reserve( sipCpp->maximum().size() );
75 for ( double max : sipCpp->maximum() )
76 {
77 maximums.append( QString::number( max ) );
78 }
79 QString str = u"<QgsRenderedLayerStatistics: %1 (min: %2 - max: %3)>"_s.arg( sipCpp->layerId(), minimums.join( ',' ), maximums.join( ',' ) );
80 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
81 % End
82#endif
83
88 QList<double> minimum() const;
89
94 double minimum( int index ) const;
95
100 QList<double> maximum() const;
101
106 double maximum( int index ) const;
107
112 void setMinimum( QList<double> &minimum );
113
119 bool setMinimum( int index, double minimum );
120
125 void setMaximum( QList<double> &maximum );
126
132 bool setMaximum( int index, double maximum );
133
134 private:
135
136 QList<double> mMin;
137 QList<double> mMax;
138};
139
140#endif // QGSRENDEREDLAYERSTATISTICS_H
QgsRenderedItemDetails(const QString &layerId)
Constructor for QgsRenderedItemDetails.
QString layerId() const
Returns the layer ID of the associated map layer.
QgsRenderedLayerStatistics(const QString &layerId, const QList< double > &minimum, const QList< double > &maximum)
Constructor for QgsRenderedLayerStatistics from a list of minimum and maximum.
QList< double > maximum() const
Returns the maximum values of the computed statistics.
void setMaximum(QList< double > &maximum)
Sets the maximum values of the computed statistics.
void setMinimum(QList< double > &minimum)
Sets the minimum values of the computed statistics.
QList< double > minimum() const
Returns the minimum values of the computed statistics.
#define SIP_TYPEHINT(type)
Definition qgis_sip.h:240