QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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 Member Functions

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

Static Public Member Functions

static QString displayName (Qgis::DateTimeStatistic statistic)
 Returns the friendly display name for a statistic.
 

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().

Definition at line 44 of file qgsdatetimestatisticalsummary.h.

Constructor & Destructor Documentation

◆ QgsDateTimeStatisticalSummary()

QgsDateTimeStatisticalSummary::QgsDateTimeStatisticalSummary ( Qgis::DateTimeStatistics  stats = Qgis::DateTimeStatistic::All)

Constructor for QgsDateTimeStatisticalSummary.

Parameters
statsflags for statistics to calculate

Definition at line 32 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 60 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 48 of file qgsdatetimestatisticalsummary.cpp.

◆ count()

int QgsDateTimeStatisticalSummary::count ( ) const
inline

Returns the calculated count of values.

Definition at line 114 of file qgsdatetimestatisticalsummary.h.

◆ countDistinct()

int QgsDateTimeStatisticalSummary::countDistinct ( ) const
inline

Returns the number of distinct datetime values.

Definition at line 119 of file qgsdatetimestatisticalsummary.h.

◆ countMissing()

int QgsDateTimeStatisticalSummary::countMissing ( ) const
inline

Returns the number of missing (null) datetime values.

Definition at line 129 of file qgsdatetimestatisticalsummary.h.

◆ displayName()

QString QgsDateTimeStatisticalSummary::displayName ( Qgis::DateTimeStatistic  statistic)
static

Returns the friendly display name for a statistic.

Parameters
statisticstatistic to return name for

Definition at line 165 of file qgsdatetimestatisticalsummary.cpp.

◆ distinctValues()

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

Returns the set of distinct datetime values.

Definition at line 124 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 89 of file qgsdatetimestatisticalsummary.cpp.

◆ max()

QDateTime QgsDateTimeStatisticalSummary::max ( ) const
inline

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

Definition at line 139 of file qgsdatetimestatisticalsummary.h.

◆ min()

QDateTime QgsDateTimeStatisticalSummary::min ( ) const
inline

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

Definition at line 134 of file qgsdatetimestatisticalsummary.h.

◆ range()

QgsInterval QgsDateTimeStatisticalSummary::range ( ) const

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

Definition at line 156 of file qgsdatetimestatisticalsummary.cpp.

◆ reset()

void QgsDateTimeStatisticalSummary::reset ( )

Resets the calculated values.

Definition at line 38 of file qgsdatetimestatisticalsummary.cpp.

◆ setStatistics()

void QgsDateTimeStatisticalSummary::setStatistics ( Qgis::DateTimeStatistics  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 67 of file qgsdatetimestatisticalsummary.h.

◆ statistic()

QVariant QgsDateTimeStatisticalSummary::statistic ( Qgis::DateTimeStatistic  stat) const

Returns the value of a specified statistic.

Parameters
statstatistic to return
Returns
calculated value of statistic

Definition at line 130 of file qgsdatetimestatisticalsummary.cpp.

◆ statistics()

Qgis::DateTimeStatistics 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 59 of file qgsdatetimestatisticalsummary.h.


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