QGIS API Documentation  3.0.2-Girona (307d082)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsDateTimeStatisticalSummary Class Reference

Calculator for summary statistics and aggregates for a list of datetimes. More...

#include <qgsdatetimestatisticalsummary.h>

Public Types

enum  Statistic {
  Count = 1, CountDistinct = 2, CountMissing = 4, Min = 8,
  Max = 16, Range = 32, All = Count | CountDistinct | CountMissing | Min | Max | Range
}
 Enumeration of flags that specify statistics to be calculated. More...
 

Public Member Functions

 QgsDateTimeStatisticalSummary (QgsDateTimeStatisticalSummary::Statistics stats=All)
 Constructor for QgsDateTimeStatisticalSummary. More...
 
void addValue (const QVariant &value)
 Adds a single datetime to the statistics calculation. More...
 
void calculate (const QVariantList &values)
 Calculates summary statistics for a list of variants. More...
 
int count () const
 Returns the calculated count of values. More...
 
int countDistinct () const
 Returns the number of distinct datetime values. More...
 
int countMissing () const
 Returns the number of missing (null) datetime values. More...
 
QSet< QDateTime > distinctValues () const
 Returns the set of distinct datetime values. More...
 
void finalize ()
 Must be called after adding all datetimes with addValue() and before retrieving any calculated datetime statistics. More...
 
QDateTime max () const
 Returns the maximum (latest) non-null datetime value. More...
 
QDateTime min () const
 Returns the minimum (earliest) non-null datetime value. More...
 
QgsInterval range () const
 Returns the range (interval between earliest and latest non-null datetime values). More...
 
void reset ()
 Resets the calculated values. More...
 
void setStatistics (Statistics stats)
 Sets flags which specify which statistics will be calculated. More...
 
QVariant statistic (QgsDateTimeStatisticalSummary::Statistic stat) const
 Returns the value of a specified statistic. More...
 
Statistics statistics () const
 Returns flags which specify which statistics will be calculated. More...
 

Static Public Member Functions

static QString displayName (QgsDateTimeStatisticalSummary::Statistic statistic)
 Returns the friendly display name for a statistic. More...
 

Detailed Description

Calculator for summary statistics and aggregates for a list of datetimes.

Statistics are calculated by calling calculate() and passing a list of datetimes. The individual statistics can then be retrieved using the associated methods. Note that not all statistics are calculated by default. Statistics which require slower computations are only calculated by specifying the statistic in the constructor or via setStatistics().

Since
QGIS 2.16

Definition at line 45 of file qgsdatetimestatisticalsummary.h.

Member Enumeration Documentation

◆ Statistic

Enumeration of flags that specify statistics to be calculated.

Enumerator
Count 

Count.

CountDistinct 

Number of distinct datetime values.

CountMissing 

Number of missing (null) values.

Min 

Minimum (earliest) datetime value.

Max 

Maximum (latest) datetime value.

Range 

Interval between earliest and latest datetime value.

All 

Definition at line 50 of file qgsdatetimestatisticalsummary.h.

Constructor & Destructor Documentation

◆ QgsDateTimeStatisticalSummary()

QgsDateTimeStatisticalSummary::QgsDateTimeStatisticalSummary ( QgsDateTimeStatisticalSummary::Statistics  stats = All)

Constructor for QgsDateTimeStatisticalSummary.

Parameters
statsflags for statistics to calculate

Definition at line 31 of file qgsdatetimestatisticalsummary.cpp.

Member Function Documentation

◆ addValue()

void QgsDateTimeStatisticalSummary::addValue ( const QVariant &  value)

Adds a single datetime to the statistics calculation.

Calling this method allows datetimes to be added to the calculation one at a time. For large quantities of dates this may be more efficient then first adding all the variants to a list and calling calculate().

Parameters
valuedatetime to add. Any non-datetime variants will be ignored.
Note
call reset() before adding the first datetime using this method to clear the results from any previous calculations
finalize() must be called after adding the final value and before retrieving calculated statistics.
See also
calculate()
finalize()

Definition at line 58 of file qgsdatetimestatisticalsummary.cpp.

◆ calculate()

void QgsDateTimeStatisticalSummary::calculate ( const QVariantList &  values)

Calculates summary statistics for a list of variants.

Any non-datetime variants will be ignored.

Parameters
valueslist of variants
See also
addValue()

Definition at line 47 of file qgsdatetimestatisticalsummary.cpp.

◆ count()

int QgsDateTimeStatisticalSummary::count ( ) const
inline

Returns the calculated count of values.

Definition at line 128 of file qgsdatetimestatisticalsummary.h.

◆ countDistinct()

int QgsDateTimeStatisticalSummary::countDistinct ( ) const
inline

Returns the number of distinct datetime values.

Definition at line 133 of file qgsdatetimestatisticalsummary.h.

◆ countMissing()

int QgsDateTimeStatisticalSummary::countMissing ( ) const
inline

Returns the number of missing (null) datetime values.

Definition at line 143 of file qgsdatetimestatisticalsummary.h.

◆ displayName()

QString QgsDateTimeStatisticalSummary::displayName ( QgsDateTimeStatisticalSummary::Statistic  statistic)
static

Returns the friendly display name for a statistic.

Parameters
statisticstatistic to return name for

Definition at line 148 of file qgsdatetimestatisticalsummary.cpp.

◆ distinctValues()

QSet< QDateTime > QgsDateTimeStatisticalSummary::distinctValues ( ) const
inline

Returns the set of distinct datetime values.

Definition at line 138 of file qgsdatetimestatisticalsummary.h.

◆ finalize()

void QgsDateTimeStatisticalSummary::finalize ( )

Must be called after adding all datetimes with addValue() and before retrieving any calculated datetime statistics.

See also
addValue()

Definition at line 85 of file qgsdatetimestatisticalsummary.cpp.

◆ max()

QDateTime QgsDateTimeStatisticalSummary::max ( ) const
inline

Returns the maximum (latest) non-null datetime value.

Definition at line 153 of file qgsdatetimestatisticalsummary.h.

◆ min()

QDateTime QgsDateTimeStatisticalSummary::min ( ) const
inline

Returns the minimum (earliest) non-null datetime value.

Definition at line 148 of file qgsdatetimestatisticalsummary.h.

◆ range()

QgsInterval QgsDateTimeStatisticalSummary::range ( ) const
inline

Returns the range (interval between earliest and latest non-null datetime values).

Definition at line 158 of file qgsdatetimestatisticalsummary.h.

◆ reset()

void QgsDateTimeStatisticalSummary::reset ( )

Resets the calculated values.

Definition at line 37 of file qgsdatetimestatisticalsummary.cpp.

◆ setStatistics()

void QgsDateTimeStatisticalSummary::setStatistics ( Statistics  stats)
inline

Sets flags which specify which statistics will be calculated.

Some statistics are always calculated (e.g., count).

Parameters
statsflags for statistics to calculate
See also
statistics

Definition at line 81 of file qgsdatetimestatisticalsummary.h.

◆ statistic()

QVariant QgsDateTimeStatisticalSummary::statistic ( QgsDateTimeStatisticalSummary::Statistic  stat) const

Returns the value of a specified statistic.

Parameters
statstatistic to return
Returns
calculated value of statistic

Definition at line 126 of file qgsdatetimestatisticalsummary.cpp.

◆ statistics()

Statistics QgsDateTimeStatisticalSummary::statistics ( ) const
inline

Returns flags which specify which statistics will be calculated.

Some statistics are always calculated (e.g., count).

See also
setStatistics

Definition at line 73 of file qgsdatetimestatisticalsummary.h.


The documentation for this class was generated from the following files: