32587 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
ea066599a1 [relations] Add method to manager to retrieve relations by name
Also
- Begin unit tests for QgsRelationManager
- Make project optional when constructing QgsRelationManager
2016-05-17 10:53:25 +10:00
Nyall Dawson
84fc3c3b3d Implement method for caching values within expression contexts
Can be used to store the results of expensive sub-expression
calculations (eg layer aggregates), so that future expression
evaluation using the same context does not have to recalculate
the cached values.
2016-05-17 10:53:24 +10:00
Nyall Dawson
821134ca91 Add method to convert string to aggregate type 2016-05-17 10:53:24 +10:00
Nyall Dawson
dcc047af49 Add possibility to handle aggregate calculation at data provider
(not implemented for any providers yet)
2016-05-17 10:53:24 +10:00
Nyall Dawson
50e41c8133 New utility class QgsAggregateCalculator, simplifies calculating
aggregates from vector layer fields and expressions
2016-05-17 10:53:24 +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
Even Rouault
2bbd5ca509 Fix look&feel of WFS SQL query composer on Mac 2016-05-17 00:33:20 +02:00
Juergen E. Fischer
c198b1afe9 indentation fix 2016-05-16 16:59:29 +02:00
Nyall Dawson
858914eef5 Ensure that providers fetch geometry for a QgsFeatureRequest
with an expression filter which requires geometry
2016-05-16 23:09:18 +10:00
Matthias Kuhn
c0214bc301 Fix bug in edit virtual field
The index was transformed twice from field index to field origin index,
resulting in a corrupted index (most often being 0 in the end).
2016-05-16 15:04:23 +02:00
Juergen E. Fischer
b514f521e6 cppcheck fixes 2016-05-16 14:14:14 +02:00
Matthias Kuhn
ee533a7dea Add test for attribute table sorting 2016-05-16 11:16:13 +02:00
Matthias Kuhn
9080aa1988 Don't require a parent for QgsExpressionBuilderWidget 2016-05-16 11:16:13 +02:00
Matthias Kuhn
d07d9edda6 Allow sorting attribute table by expression 2016-05-16 11:16:13 +02:00
Nyall Dawson
11ee2fc809 Fix running unsaved script in console 2016-05-16 18:14:58 +10:00
Juergen E. Fischer
d64f47404b fix precise build 2016-05-16 08:48:36 +02:00
Juergen E. Fischer
3d44a1e6e2 fix windows build 2016-05-15 23:56:53 +02:00
Nyall Dawson
8fd86a6b87 Fix debug build 2016-05-16 07:53:19 +10:00
Nyall Dawson
5c7f4c7664 Merge pull request #3072 from rouault/qt5_fix_testqgsfield
Make qgis_fieldtest all Qt 5.X compatible
2016-05-16 07:04:43 +10:00
Even Rouault
c4819adea4 Merge remote-tracking branch 'rouault/fix_qt5_wfs_ogcutils_tests' 2016-05-15 21:30:56 +02:00
Even Rouault
202420c70a Make qgis_fieldtest all Qt 5.X compatible
In https://codereview.qt-project.org/#/c/99815/ implemented in QT 5.5,
doubles are converted to strings using '%.17g', so short decimal values
might be expanded to long strings depending on their values.
https://wiki.qt.io/New_Features_in_Qt_5.7 has a logic to avoid this, but
if we select carefully the double to have both an exact binary and decimal
representation, that can work will all versions.

$ python -c "print('%.17g' % 9.7)"
9.6999999999999993

$ python -c "print('%.17g' % 1.25)"
1.25
2016-05-15 19:44:13 +02:00
Even Rouault
9a49c6aace Make ogcutils and WFS tests Qt 5 compatible 2016-05-15 19:17:58 +02:00
Even Rouault
bf91a8b61b WFS provider, connections dialog: change way that we select current index in the tree view of layers to be QT 5 compatible and not require showing the widget in tests 2016-05-15 19:17:57 +02:00
Nyall Dawson
63cab56839 Avoid iterating over temporary container 2016-05-15 20:50:45 +10:00
Nyall Dawson
a3d6227e2e Avoid detaching temporary containers 2016-05-15 20:50:44 +10:00
Nyall Dawson
e25ffc4781 Avoid unnecessary temporary container and double iteration over
containers by directly iterating over container itself, rather
then iterating over .keys()/.values()
2016-05-15 20:50:44 +10:00
Nyall Dawson
77c4ed5054 Use more efficient QString multiple arg variant rather then
chaining .arg calls
2016-05-15 20:50:44 +10:00
Nyall Dawson
239865b708 Add missing references to Q_FOREACH loops 2016-05-15 20:50:43 +10:00
Nyall Dawson
0b940caccc Use QString::at(0) instead of left(1), since it's more efficient
and doesn't allocate a QString
2016-05-15 20:50:43 +10:00
Nyall Dawson
1c1b8aac25 Switch private QList to more efficient QVector container 2016-05-15 20:50:43 +10:00
Nyall Dawson
d255bfb256 Remove unused variables, also avoid some unnecessary string creation
when not using debug builds
2016-05-15 20:50:42 +10:00
Nyall Dawson
bf76049d33 Fix some Coverity uninitialized variable warnings 2016-05-15 20:38:38 +10:00
Nyall Dawson
c732c68749 [travis] Run tests even with build failures on osx 2016-05-15 20:38:38 +10:00
Nyall Dawson
c1d84dee96 Include travis build name in dash results (ie qt5/qt4) 2016-05-15 20:38:38 +10:00
Nyall Dawson
57d114e2e2 Update test masks for Qt5, enable labeling tests 2016-05-15 20:38:38 +10:00
Even Rouault
e5e78af8a1 Fixes in qgswebframe.h and qgswebpage.h to fix building without QtWebKit 2016-05-14 20:45:01 +02:00
Jürgen Fischer
ae7666fad3 Merge pull request #3070 from sebastic/qtermwidget-hurd
Add support for GNU/Hurd to GRASS plugin qtermwidget/kpty.cpp.
2016-05-14 19:09:51 +02:00
Bas Couwenberg
666050c57c Add support for GNU/Hurd to GRASS plugin qtermwidget/kpty.cpp.
The GNU/Hurd porting guidelines document the following:
"
 Missing termio.h

 Change it to use termios.h (check for it properly with autoconf
 HAVE_TERMIOS_H or the __GLIBC__ macro)

 Also, change calls to ioctl(fd, TCGETS, ...) and ioctl(fd, TCSETS, ...)
 with tcgetattr(fd, ...) and tcsetattr(fd, ...).
"
https://www.gnu.org/software/hurd/hurd/porting/guidelines.html#Missing_termio_h_tt_
2016-05-14 18:45:32 +02:00
Even Rouault
45e7da15e1 OGR provider: fix Coverity warning about mFetchGeometry member being not always initialized 2016-05-14 17:57:00 +02:00
Even Rouault
349a618a9e qgsgml & WFS provider: fix Coverity warnings introduced in recent WFS works 2016-05-14 14:42:34 +02:00
Even Rouault
abd182c50c Merge pull request #3061 from rouault/saveas_human_readable_values
[FEATURE] Export vector layer with "human-readable" values from edit widgets
2016-05-14 14:23:10 +02:00
Even Rouault
90cc0ed495 QgsVectorLayerSaveAsDialog: add checkboxes to decide which fields should be exported with their displayed values, and bind it in QgisApp with QgsVectorFileWriter 2016-05-14 12:33:10 +02:00
Even Rouault
038b3b7950 QgsVectorFileWriter: add capability to export displayed values of fields (typically coming from edit widgets) instead of their raw values 2016-05-14 12:33:10 +02:00
aharfoot
cfb6100389 Disable FEATURE_DATASET layer option if its value is not set 2016-05-14 08:55:23 +02:00
Matthias Kuhn
894d520018 Merge pull request #2621 from simonsonc/georef-crosshairs
Make the georeferencer tool use a snapping cursor
2016-05-14 00:47:51 +02:00
Sebastian Dietrich
c5308754eb [DbManager] allow to refresh materialized views
(fixes #13697)
2016-05-14 00:41:20 +02:00
Matthias Kuhn
10134587ed Add note for failing Qt5 test 2016-05-14 00:38:19 +02:00
Matthias Kuhn
a349e702cc Fix from PyQt.xy > from qgis.PyQt.xy import leftovers 2016-05-14 00:38:19 +02:00