QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsaggregatecalculator.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsaggregatecalculator.h
3
------------------------
4
begin : May 2016
5
copyright : (C) 2016 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSAGGREGATECALCULATOR_H
19
#define QGSAGGREGATECALCULATOR_H
20
21
#include "qgis_core.h"
22
#include "
qgsfeatureid.h
"
23
#include "
qgsfeaturerequest.h
"
24
#include "
qgsstatisticalsummary.h
"
25
26
#include <QVariant>
27
28
class
QgsFeatureIterator
;
29
class
QgsExpression
;
30
class
QgsVectorLayer
;
31
class
QgsExpressionContext
;
32
42
class
CORE_EXPORT
QgsAggregateCalculator
43
{
44
public
:
49
struct
AggregateInfo
50
{
52
QString
function
;
54
QString
name
;
56
QSet<QMetaType::Type>
supportedTypes
;
57
};
58
60
struct
AggregateParameters
61
{
68
QString
filter
;
69
75
QString
delimiter
;
76
81
QgsFeatureRequest::OrderBy
orderBy
;
82
};
83
88
QgsAggregateCalculator
(
const
QgsVectorLayer
*
layer
);
89
95
QString
lastError
()
const
{
return
mLastError; }
96
100
const
QgsVectorLayer
*layer()
const
;
101
106
void
setParameters(
const
AggregateParameters ¶meters );
107
113
void
setFilter
(
const
QString &filterExpression ) { mFilterExpression = filterExpression; }
114
121
void
setFidsFilter(
const
QgsFeatureIds
&fids );
122
127
QString
filter
()
const
{
return
mFilterExpression; }
128
134
void
setDelimiter
(
const
QString &
delimiter
) { mDelimiter =
delimiter
; }
135
140
QString
delimiter
()
const
{
return
mDelimiter; }
141
153
QVariant calculate(
Qgis::Aggregate
aggregate,
const
QString &fieldOrExpression,
QgsExpressionContext
*context =
nullptr
,
bool
*ok =
nullptr
,
QgsFeedback
*feedback =
nullptr
)
const
;
154
161
static
Qgis::Aggregate
stringToAggregate(
const
QString &
string
,
bool
*ok =
nullptr
);
162
167
static
QString displayName(
Qgis::Aggregate
aggregate );
168
174
static
QList< QgsAggregateCalculator::AggregateInfo > aggregates();
175
176
private
:
178
const
QgsVectorLayer
*mLayer =
nullptr
;
179
181
QString mFilterExpression;
182
184
QgsFeatureRequest::OrderBy
mOrderBy;
185
187
QString mDelimiter;
188
190
QgsFeatureIds
mFidsFilter;
191
192
//trigger variable
193
bool
mFidsSet =
false
;
194
195
mutable
QString mLastError;
196
197
static
Qgis::Statistic
numericStatFromAggregate(
Qgis::Aggregate
aggregate,
bool
*ok =
nullptr
);
198
static
Qgis::StringStatistic
stringStatFromAggregate(
Qgis::Aggregate
aggregate,
bool
*ok =
nullptr
);
199
static
Qgis::DateTimeStatistic
dateTimeStatFromAggregate(
Qgis::Aggregate
aggregate,
bool
*ok =
nullptr
);
200
201
static
QVariant calculateNumericAggregate(
QgsFeatureIterator
&fit,
int
attr,
QgsExpression
*expression,
QgsExpressionContext
*context,
Qgis::Statistic
stat );
202
203
static
QVariant calculateStringAggregate(
QgsFeatureIterator
&fit,
int
attr,
QgsExpression
*expression,
QgsExpressionContext
*context,
Qgis::StringStatistic
stat );
204
205
static
QVariant calculateDateTimeAggregate(
QgsFeatureIterator
&fit,
int
attr,
QgsExpression
*expression,
QgsExpressionContext
*context,
Qgis::DateTimeStatistic
stat );
206
static
QVariant calculateGeometryAggregate(
QgsFeatureIterator
&fit,
QgsExpression
*expression,
QgsExpressionContext
*context );
207
208
static
QVariant calculateArrayAggregate(
QgsFeatureIterator
&fit,
int
attr,
QgsExpression
*expression,
QgsExpressionContext
*context );
209
210
static
QVariant calculate(
211
Qgis::Aggregate
aggregate,
212
QgsFeatureIterator
&fit,
213
QMetaType::Type resultType,
214
int
attr,
215
QgsExpression
*expression,
216
const
QString &delimiter,
217
QgsExpressionContext
*context,
218
bool
*ok =
nullptr
,
219
QString *error =
nullptr
220
);
221
static
QVariant concatenateStrings(
QgsFeatureIterator
&fit,
int
attr,
QgsExpression
*expression,
QgsExpressionContext
*context,
const
QString &delimiter,
bool
unique =
false
);
222
223
QVariant defaultValue(
Qgis::Aggregate
aggregate )
const
;
224
};
225
226
#endif
//QGSAGGREGATECALCULATOR_H
Qgis::Statistic
Statistic
Available generic statistics.
Definition
qgis.h:6670
Qgis::StringStatistic
StringStatistic
Available string statistics.
Definition
qgis.h:6732
Qgis::Aggregate
Aggregate
Available aggregates to calculate.
Definition
qgis.h:6638
Qgis::DateTimeStatistic
DateTimeStatistic
Available date/time statistics.
Definition
qgis.h:6707
QgsAggregateCalculator::setFilter
void setFilter(const QString &filterExpression)
Sets a filter to limit the features used during the aggregate calculation.
Definition
qgsaggregatecalculator.h:113
QgsAggregateCalculator::layer
const QgsVectorLayer * layer() const
Returns the associated vector layer.
Definition
qgsaggregatecalculator.cpp:40
QgsAggregateCalculator::setDelimiter
void setDelimiter(const QString &delimiter)
Sets the delimiter to use for joining values with the StringConcatenate aggregate.
Definition
qgsaggregatecalculator.h:134
QgsAggregateCalculator::lastError
QString lastError() const
Returns the last error encountered during the aggregate calculation.
Definition
qgsaggregatecalculator.h:95
QgsAggregateCalculator::filter
QString filter() const
Returns the filter which limits the features used during the aggregate calculation.
Definition
qgsaggregatecalculator.h:127
QgsAggregateCalculator::delimiter
QString delimiter() const
Returns the delimiter used for joining values with the StringConcatenate aggregate.
Definition
qgsaggregatecalculator.h:140
QgsAggregateCalculator::QgsAggregateCalculator
QgsAggregateCalculator(const QgsVectorLayer *layer)
Constructor for QgsAggregateCalculator.
Definition
qgsaggregatecalculator.cpp:36
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition
qgsexpressioncontext.h:491
QgsExpression
Handles parsing and evaluation of expressions (formerly called "search strings").
Definition
qgsexpression.h:198
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition
qgsfeatureiterator.h:284
QgsFeatureRequest::OrderBy
Represents a list of OrderByClauses, with the most important first and the least important last.
Definition
qgsfeaturerequest.h:211
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition
qgsfeedback.h:44
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
qgsfeatureid.h
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition
qgsfeatureid.h:41
qgsfeaturerequest.h
qgsstatisticalsummary.h
QgsAggregateCalculator::AggregateInfo
Structured information about the available aggregates.
Definition
qgsaggregatecalculator.h:50
QgsAggregateCalculator::AggregateInfo::name
QString name
A translated, human readable name.
Definition
qgsaggregatecalculator.h:54
QgsAggregateCalculator::AggregateInfo::function
QString function
The expression function.
Definition
qgsaggregatecalculator.h:52
QgsAggregateCalculator::AggregateInfo::supportedTypes
QSet< QMetaType::Type > supportedTypes
This aggregate function can only be used with these datatypes.
Definition
qgsaggregatecalculator.h:56
QgsAggregateCalculator::AggregateParameters
A bundle of parameters controlling aggregate calculation.
Definition
qgsaggregatecalculator.h:61
QgsAggregateCalculator::AggregateParameters::filter
QString filter
Optional filter for calculating aggregate over a subset of features, or an empty string to use all fe...
Definition
qgsaggregatecalculator.h:68
QgsAggregateCalculator::AggregateParameters::delimiter
QString delimiter
Delimiter to use for joining values with the StringConcatenate aggregate.
Definition
qgsaggregatecalculator.h:75
QgsAggregateCalculator::AggregateParameters::orderBy
QgsFeatureRequest::OrderBy orderBy
Optional order by clauses.
Definition
qgsaggregatecalculator.h:81
Generated on
for QGIS API Documentation by
1.17.0