QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
45 QgsRenderedLayerStatistics( const QString &layerId, const QList<double> &minimum, const QList<double> &maximum );
46
50#ifndef SIP_RUN
51 QgsRenderedLayerStatistics( const QString &layerId, double minimum = std::numeric_limits<double>::quiet_NaN(), double maximum = std::numeric_limits<double>::quiet_NaN() );
52#else
53 // clang-format off
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// clang-format on
63#endif
64
65#ifdef SIP_RUN
66 // clang-format off
67 SIP_PYOBJECT __repr__();
68 % MethodCode
69 QStringList minimums;
70 minimums.reserve( sipCpp->minimum().size() );
71 for ( double min : sipCpp->minimum() )
72 {
73 minimums.append( QString::number( min ) );
74 }
75 QStringList maximums;
76 maximums.reserve( sipCpp->maximum().size() );
77 for ( double max : sipCpp->maximum() )
78 {
79 maximums.append( QString::number( max ) );
80 }
81 QString str = u"<QgsRenderedLayerStatistics: %1 (min: %2 - max: %3)>"_s.arg( sipCpp->layerId(), minimums.join( ',' ), maximums.join( ',' ) );
82 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
83 % End
84// clang-format on
85#endif
86
91 QList<double> minimum() const;
92
97 double minimum( int index ) const;
98
103 QList<double> maximum() const;
104
109 double maximum( int index ) const;
110
115 void setMinimum( QList<double> &minimum );
116
122 bool setMinimum( int index, double minimum );
123
128 void setMaximum( QList<double> &maximum );
129
135 bool setMaximum( int index, double maximum );
136
137 private:
138 QList<double> mMin;
139 QList<double> mMax;
140};
141
142#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:239