QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 "qgis_core.h"
21#include "qgis_sip.h"
23
24#include <limits>
25
26
33{
34 public:
35
43 QgsRenderedLayerStatistics( const QString &layerId, const QList<double> &minimum, const QList<double> &maximum );
44
48#ifndef SIP_RUN
49 QgsRenderedLayerStatistics( const QString &layerId, double minimum = std::numeric_limits<double>::quiet_NaN(), double maximum = std::numeric_limits<double>::quiet_NaN() );
50#else
51 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 )];
52 % MethodCode
53 double minP = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
54 double maxP = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
55 QList<double> minL = {minP};
56 QList<double> maxL = {maxP};
57 sipCpp = new sipQgsRenderedLayerStatistics( *a0, minL, maxL );
58 % End
59#endif
60
61#ifdef SIP_RUN
62 SIP_PYOBJECT __repr__();
63 % MethodCode
64 QStringList minimums;
65 minimums.reserve( sipCpp->minimum().size() );
66 for ( double min : sipCpp->minimum() )
67 {
68 minimums.append( QString::number( min ) );
69 }
70 QStringList maximums;
71 maximums.reserve( sipCpp->maximum().size() );
72 for ( double max : sipCpp->maximum() )
73 {
74 maximums.append( QString::number( max ) );
75 }
76 QString str = QStringLiteral( "<QgsRenderedLayerStatistics: %1 (min: %2 - max: %3)>" ).arg( sipCpp->layerId(), minimums.join( ',' ), maximums.join( ',' ) );
77 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
78 % End
79#endif
80
85 QList<double> minimum() const;
86
91 double minimum( int index ) const;
92
97 QList<double> maximum() const;
98
103 double maximum( int index ) const;
104
109 void setMinimum( QList<double> &minimum );
110
116 bool setMinimum( int index, double minimum );
117
122 void setMaximum( QList<double> &maximum );
123
129 bool setMaximum( int index, double maximum );
130
131 private:
132
133 QList<double> mMin;
134 QList<double> mMax;
135};
136
137#endif // QGSRENDEREDLAYERSTATISTICS_H
Base class for detailed information about a rendered item.
QString layerId() const
Returns the layer ID of the associated map layer.
Contains computed statistics for a layer render.
#define SIP_TYPEHINT(type)
Definition qgis_sip.h:232