QGIS API Documentation
3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
src
core
qgsdatetimestatisticalsummary.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsdatetimestatisticalsummary.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 QGSDATETIMESTATISTICALSUMMARY_H
17
#define QGSDATETIMESTATISTICALSUMMARY_H
18
19
#include "qgis_core.h"
20
#include "
qgis_sip.h
"
21
#include "
qgsinterval.h
"
22
#include <QSet>
23
#include <QDateTime>
24
#include <QVariantList>
25
26
/***************************************************************************
27
* This class is considered CRITICAL and any change MUST be accompanied with
28
* full unit tests in test_qgsdatetimestatisticalsummary.py.
29
* See details in QEP #17
30
****************************************************************************/
31
45
class
CORE_EXPORT
QgsDateTimeStatisticalSummary
46
{
47
public
:
48
50
enum
Statistic
51
{
52
Count = 1,
53
CountDistinct = 2,
54
CountMissing = 4,
55
Min = 8,
56
Max = 16,
57
Range = 32,
58
All = Count | CountDistinct | CountMissing | Min | Max | Range,
59
};
60
Q_DECLARE_FLAGS( Statistics, Statistic )
61
62
66
QgsDateTimeStatisticalSummary
( QgsDateTimeStatisticalSummary::Statistics stats = All );
67
73
Statistics
statistics
()
const
{
return
mStatistics; }
74
81
void
setStatistics
( Statistics stats ) { mStatistics = stats; }
82
86
void
reset();
87
94
void
calculate(
const
QVariantList &values );
95
109
void
addValue(
const
QVariant &value );
110
116
void
finalize();
117
123
QVariant statistic(
QgsDateTimeStatisticalSummary::Statistic
stat )
const
;
124
128
int
count
()
const
{
return
mCount; }
129
133
int
countDistinct
()
const
{
return
mValues.count(); }
134
138
QSet< QDateTime >
distinctValues
()
const
{
return
mValues; }
139
143
int
countMissing
()
const
{
return
mCountMissing; }
144
148
QDateTime
min
()
const
{
return
mMin; }
149
153
QDateTime
max
()
const
{
return
mMax; }
154
158
QgsInterval
range
()
const
{
return
mMax - mMin; }
159
164
static
QString displayName(
QgsDateTimeStatisticalSummary::Statistic
statistic );
165
166
private
:
167
168
Statistics mStatistics;
169
170
int
mCount;
171
QSet< QDateTime > mValues;
172
int
mCountMissing;
173
QDateTime mMin;
174
QDateTime mMax;
175
bool
mIsTimes;
176
177
void
testDateTime(
const
QDateTime &dateTime,
bool
isNull );
178
};
179
180
Q_DECLARE_OPERATORS_FOR_FLAGS
( QgsDateTimeStatisticalSummary::Statistics )
181
182
#endif
// QGSDATETIMESTATISTICALSUMMARY_H
QgsDateTimeStatisticalSummary
Calculator for summary statistics and aggregates for a list of datetimes.
Definition
qgsdatetimestatisticalsummary.h:46
QgsDateTimeStatisticalSummary::range
QgsInterval range() const
Returns the range (interval between earliest and latest non-null datetime values).
Definition
qgsdatetimestatisticalsummary.h:158
QgsDateTimeStatisticalSummary::min
QDateTime min() const
Returns the minimum (earliest) non-null datetime value.
Definition
qgsdatetimestatisticalsummary.h:148
QgsDateTimeStatisticalSummary::Statistic
Statistic
Enumeration of flags that specify statistics to be calculated.
Definition
qgsdatetimestatisticalsummary.h:51
QgsDateTimeStatisticalSummary::count
int count() const
Returns the calculated count of values.
Definition
qgsdatetimestatisticalsummary.h:128
QgsDateTimeStatisticalSummary::statistics
Statistics statistics() const
Returns flags which specify which statistics will be calculated.
Definition
qgsdatetimestatisticalsummary.h:73
QgsDateTimeStatisticalSummary::setStatistics
void setStatistics(Statistics stats)
Sets flags which specify which statistics will be calculated.
Definition
qgsdatetimestatisticalsummary.h:81
QgsDateTimeStatisticalSummary::countMissing
int countMissing() const
Returns the number of missing (null) datetime values.
Definition
qgsdatetimestatisticalsummary.h:143
QgsDateTimeStatisticalSummary::countDistinct
int countDistinct() const
Returns the number of distinct datetime values.
Definition
qgsdatetimestatisticalsummary.h:133
QgsDateTimeStatisticalSummary::distinctValues
QSet< QDateTime > distinctValues() const
Returns the set of distinct datetime values.
Definition
qgsdatetimestatisticalsummary.h:138
QgsDateTimeStatisticalSummary::max
QDateTime max() const
Returns the maximum (latest) non-null datetime value.
Definition
qgsdatetimestatisticalsummary.h:153
QgsInterval
A representation of the interval between two datetime values.
Definition
qgsinterval.h:42
qgis_sip.h
qgsinterval.h
Q_DECLARE_OPERATORS_FOR_FLAGS
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
Generated on Mon Oct 30 2023 18:42:25 for QGIS API Documentation by
1.9.8