9 Commits

Author SHA1 Message Date
Nyall Dawson
307aabd66a [FEATURE] Aggregates for expressions
This commit adds a number of different forms of aggregates to
the expression engine.

1. Aggregates within the current layer, eg sum("passengers")
Supports sub expressions (ie sum("passengers"/2) ), group by
( sum("passengers", group_by:="line_segment") ), and optional
filters ( sum("passengers", filter:= "station_class" > 3 ) )

2. Relational aggregates, which calculate an aggregate over
all matching child features from a relation, eg
relation_aggregate( 'my_relation', 'mean', "some_child_field" )

3. A summary aggregate function, for calculating aggregates
on other layers. Eg aggregate('rail_station_layer','sum',"passengers")
The summary aggregate function supports an optional filter,
making it possible to calculate things like:

aggregate('rail_stations','sum',"passengers",
  intersects(@atlas_geometry, $geometry ) )

for calculating the total number of passengers for the stations
inside the current atlas feature

In all cases the calculations are cached inside the expression
context, so they only need to be calculated once for each
set of expression evaluations.

Sponsored by Kanton of Zug, Switzerland
2016-05-17 10:53:25 +10:00
Nyall Dawson
1c45b940a8 Add calculation of number of null values to QgsStatisticalSummary 2016-05-17 10:53:04 +10:00
Nyall Dawson
4dea723cae Add methods to stats calculators to accept values one at a time
This can be more efficient for large quantities of values, since
it avoids the need to create a list of all values in advance
2016-05-17 10:52:06 +10:00
Nyall Dawson
e15962eea9 [processing] Use QgsStatisticalSummary for statistic calculations
For BasicStatisticssNumbers and StatisticsByCategories algorithms.
Adds extra stats (minority, majority, 1st/3rd quartile and IQR) while
avoiding custom statistics calculation code.
2015-11-16 15:04:34 +11:00
Nyall Dawson
c49b5b777f Change a lot of arguments to const references in core/gui
Rationale:
- there was a lot of large objects passed by value, so potentially
there's a speed bump from this
- even for implicitly shared classes like QString/QList there's still
a (small) cost for copying the objects when there's no reason to
- it's the right thing to do!
2015-10-07 12:02:04 +11:00
Nyall Dawson
e7b7549c29 [FEATURE] New statistical summary dock widget
Can display summary statistics (eg mean, standard deviation, ...)
for a field or expression from a vector layer.
2015-05-23 04:35:11 +10:00
Juergen E. Fischer
edeafa95ac indentation and minor sip updates 2015-05-03 17:10:32 +02:00
Nyall Dawson
31e8611230 Add quartiles and IQR to QgsStatisticalSummary calculations 2015-05-03 20:48:22 +10:00
Nyall Dawson
154468bd84 Add QgsStatisticalSummary class for calculating stats from a list
of values.
2015-05-02 23:19:39 +10:00