QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsstringstatisticalsummary.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsstringstatisticalsummary.h
3
-----------------------------
4
Date : May 2016
5
Copyright : (C) 2016 by Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSSTRINGSTATISTICALSUMMARY_H
17
#define QGSSTRINGSTATISTICALSUMMARY_H
18
19
#include "
qgis.h
"
20
#include "qgis_core.h"
21
22
#include <QSet>
23
#include <QVariantList>
24
25
/***************************************************************************
26
* This class is considered CRITICAL and any change MUST be accompanied with
27
* full unit tests in test_qgsstringstatisticalsummary.py.
28
* See details in QEP #17
29
****************************************************************************/
30
42
43
class
CORE_EXPORT
QgsStringStatisticalSummary
44
{
45
public
:
50
QgsStringStatisticalSummary
(
Qgis::StringStatistics
stats =
Qgis::StringStatistic::All
);
51
57
Qgis::StringStatistics
statistics
()
const
{
return
mStatistics; }
58
65
void
setStatistics
(
Qgis::StringStatistics
stats ) { mStatistics = stats; }
66
70
void
reset();
71
78
void
calculate(
const
QStringList &values );
79
87
void
calculateFromVariants(
const
QVariantList &values );
88
103
void
addString(
const
QString &
string
);
104
118
void
addValue(
const
QVariant &value );
119
125
void
finalize();
126
132
QVariant statistic(
Qgis::StringStatistic
stat )
const
;
133
137
int
count
()
const
{
return
mCount; }
138
143
int
countDistinct
()
const
{
return
mValues.count(); }
144
149
QSet< QString > distinctValues()
const
;
150
154
int
countMissing
()
const
{
return
mCountMissing; }
155
159
QString
min
()
const
{
return
mMin; }
160
164
QString
max
()
const
{
return
mMax; }
165
169
int
minLength
()
const
{
return
mMinLength; }
170
174
int
maxLength
()
const
{
return
mMaxLength; }
175
179
double
meanLength
()
const
{
return
mMeanLength; }
180
189
QString
minority
()
const
{
return
mMinority; }
190
199
QString
majority
()
const
{
return
mMajority; }
200
205
static
QString displayName(
Qgis::StringStatistic
statistic );
206
207
private
:
208
Qgis::StringStatistics
mStatistics;
209
210
int
mCount;
211
QMap< QString, int > mValues;
212
int
mCountMissing;
213
QString mMin;
214
QString mMax;
215
int
mMinLength;
216
int
mMaxLength;
217
long
mSumLengths;
218
double
mMeanLength;
219
QString mMinority;
220
QString mMajority;
221
222
void
testString(
const
QString &
string
);
223
};
224
225
#endif
// QGSSTRINGSTATISTICALSUMMARY_H
Qgis::StringStatistics
QFlags< StringStatistic > StringStatistics
Statistics to be calculated for string values.
Definition
qgis.h:6752
Qgis::StringStatistic
StringStatistic
Available string statistics.
Definition
qgis.h:6732
Qgis::StringStatistic::All
@ All
All statistics.
Definition
qgis.h:6743
QgsStringStatisticalSummary::setStatistics
void setStatistics(Qgis::StringStatistics stats)
Sets flags which specify which statistics will be calculated.
Definition
qgsstringstatisticalsummary.h:65
QgsStringStatisticalSummary::max
QString max() const
Returns the maximum (non-null) string value.
Definition
qgsstringstatisticalsummary.h:164
QgsStringStatisticalSummary::QgsStringStatisticalSummary
QgsStringStatisticalSummary(Qgis::StringStatistics stats=Qgis::StringStatistic::All)
Constructor for QgsStringStatistics.
Definition
qgsstringstatisticalsummary.cpp:34
QgsStringStatisticalSummary::min
QString min() const
Returns the minimum (non-null) string value.
Definition
qgsstringstatisticalsummary.h:159
QgsStringStatisticalSummary::countMissing
int countMissing() const
Returns the number of missing (null) string values.
Definition
qgsstringstatisticalsummary.h:154
QgsStringStatisticalSummary::count
int count() const
Returns the calculated count of values.
Definition
qgsstringstatisticalsummary.h:137
QgsStringStatisticalSummary::countDistinct
int countDistinct() const
Returns the number of distinct string values.
Definition
qgsstringstatisticalsummary.h:143
QgsStringStatisticalSummary::minLength
int minLength() const
Returns the minimum length of strings.
Definition
qgsstringstatisticalsummary.h:169
QgsStringStatisticalSummary::maxLength
int maxLength() const
Returns the maximum length of strings.
Definition
qgsstringstatisticalsummary.h:174
QgsStringStatisticalSummary::majority
QString majority() const
Returns the most common string.
Definition
qgsstringstatisticalsummary.h:199
QgsStringStatisticalSummary::statistics
Qgis::StringStatistics statistics() const
Returns flags which specify which statistics will be calculated.
Definition
qgsstringstatisticalsummary.h:57
QgsStringStatisticalSummary::minority
QString minority() const
Returns the least common string.
Definition
qgsstringstatisticalsummary.h:189
QgsStringStatisticalSummary::meanLength
double meanLength() const
Returns the mean length of strings.
Definition
qgsstringstatisticalsummary.h:179
qgis.h
Generated on
for QGIS API Documentation by
1.17.0