39 Commits

Author SHA1 Message Date
Harrissou Sant-anna
386fcc67ab Add more example 2016-05-24 12:24:12 +02:00
Harrissou Sant-anna
1a3c41657f Add more example 2016-05-24 12:21:00 +02:00
Denis Rouzaud
69a8c381ab Precise that scale function returns the denominator and not the scale itself 2016-05-18 10:43:19 +02:00
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
fd7a4bd900 [FEATURE] New project(point, distance, bearing) expression function
Projects a point geometry by the specified distance and bearing
2016-04-06 20:55:26 +10:00
Nyall Dawson
ae00eb965c [FEATURE] Allow expression functions to use named parameters
This commit sets the framework for allowing expression functions to
use named parameters. Ie, instead of:

clamp(1,2,3)

you can use:

clamp( min:=1, value:=2, max:=3)

This also allows arguments to be switched, eg:

clamp( value:=2, max:=3, min:=1)

Additionally, it allows for a more structured definition of function
parameters to handle optional arguments and default values for
parameters. These are currently being done using a hacky infinite
argument list.

I've utilised the postgres ':=' syntax for specifying named arguments
to avoid potential collisions which may arise with the equality test
if we re-used just the '=' operator alone.

Sponsored by North Road
2016-04-04 13:59:13 +10:00
Matthias Kuhn
ec17e3cc8e Fix expression "if" documentation 2016-03-31 13:13:32 +02:00
Harrissou Sant-anna
b3edfa8080 Fix if function example 2016-03-31 13:12:35 +02:00
Juergen E. Fischer
b89956e247 fix linebreaks in function help and CASE (fixes #14189) 2016-02-26 00:27:48 +01:00
Nyall Dawson
c23e3096fe More descriptive function help for area/length/perimeter functions
...which better clarify how project ellipsoid and unit settings are
respected by the functions
2016-02-23 11:48:10 +11:00
Matthias Kuhn
a2030d53fe Fix 2.5D renderer problem when order of walls matters
E.g. when the walls have different styles
2016-01-15 16:23:13 +01:00
Nyall Dawson
275eb9463d [FEATURE] Add closest_point and shortest_line expression functions
closest_point: returns closest point a geometry to a second geometry
shortest_line: returns the shortest possible line joining two
geometries
2016-01-15 12:50:17 +11:00
Matthias Kuhn
542541007c Add extrude function to QgsGeometry 2016-01-14 12:28:31 +01:00
Matthias Kuhn
b7170b82d3 Add azimuth function 2016-01-13 11:14:25 +01:00
Nyall Dawson
5b244ae88c [FEATURE] More geometry functions for expressions
- add accessors: geometry_n, interior_ring_n
- add num_geometries, num_rings, num_interior_rings
- add nodes_to_points for converting every node in a geometry
to a multipoint geometry
- add segments_to_lines for converting every segment in a geometry
to a multiline geometry

nodes_to_points and segments_to_lines are intended for use with
geometry generator symbology, eg to allow use of m and z values
for nodes/lines with data defined symbology.
2015-12-15 11:22:39 +11:00
Nyall Dawson
ceddb7eb97 [FEATURE] is_closed function for expressions
Returns whether a linestring is closed
2015-12-13 22:06:22 +11:00
Nyall Dawson
262514d97d [FEATURE] exterior_ring function for expressions
Returns exterior ring of a polygon as a line. Useful for geometry
generator symbology for styling only the exterior ring of
polygons.
2015-12-13 20:11:19 +11:00
nirvn
35fea9c986 [expression] add point_on_surface function 2015-12-12 17:16:34 +07:00
Matthias Kuhn
28cabbe4d0 [Expression] radians and degrees 2015-12-10 00:41:42 +01:00
nirvn
a5d670233b [FEATURE] add darker() and lighter() expression functions 2015-12-09 15:50:59 +11:00
Matthias Kuhn
4b3083d9a7 [FEATURE] Add translate expression function
Funded by
 * Regional Council of Picardy
 * ADUGA
 * Ville de Nyon
 * Wetu GIT cc
2015-12-08 08:49:05 +01:00
Matthias Kuhn
f961ecef46 [FEATURE] Add an eval expression
Funded by
 * Regional Council of Picardy
 * ADUGA
 * Ville de Nyon
 * Wetu GIT cc
2015-12-08 08:43:45 +01:00
Nyall Dawson
da436f926b [FEATURE] New 'reverse' expression for reversing linestrings 2015-11-26 16:53:55 +11:00
Juergen E. Fischer
90053c52d6 also update strpos function help (followup 2a557db) 2015-11-20 19:53:30 +01:00
Nyall Dawson
de1540357b [expressions] Add make_line and make_polygon functions 2015-11-06 20:09:48 +11:00
Nyall Dawson
12e34f2672 [expressions] Allow make_point to accept z/m values, add new
make_point_m for creation of PointM geometries. Also add
m(point) and z(point) functions for retrieving z/m value of
a point or node.
2015-11-06 20:09:13 +11:00
Nyall Dawson
da942233e7 Add DE-9IM variant which tests against a specified pattern
(available in PyQGIS/expression engine)
2015-11-04 16:03:55 +11:00
Nyall Dawson
9d4e995de6 [FEATURE] Add geometry relation DE-9IM expression function 2015-10-26 22:46:53 +11:00
Juergen E. Fischer
3c324c9985 fix lpad/rpad context help (followup b46cbbe) 2015-09-27 01:52:20 +02:00
Juergen E. Fischer
b46cbbe425 fix mixup between lpad/rpad help (fixes #13433) 2015-09-26 21:32:27 +02:00
Nyall Dawson
a4d980d055 Port from expressions+ plugin: color_part, set_color_part, day_of_week 2015-09-21 19:57:58 +10:00
Juergen E. Fischer
82b34afe03 move remaining function_help to json and update it's translation handling 2015-09-20 18:35:27 +02:00
Matthias Kuhn
2a6cff403b More examples for the expression function help 2015-09-20 13:59:54 +02:00
Matthias Kuhn
b2c404d17c Improve expression help 2015-09-20 13:51:10 +02:00
Nyall Dawson
55027e545f Clean up and extend expression geometry functions:
- New expression functions for area(geom), perimeter(geom),
point_n(geom), start_point(geom), end_point(geom), make_point(x,y)
- Add new variant to length() function which takes a geometry object,
allows for length(geom) evaluation.
- Rename x_at, y_at to $x_at, $y_at (alias old names) to reflect that
these only work on current feature geometry
- Add x(geom), y(geom) functions which return x and y coordinate
for point geometries or centroid x/y for non-point geometries
(fix #11008)
2015-09-18 09:09:09 +10:00
Sandro Santilli
55dbc041a8 [FEATURE] Add num_points(geometry) support in expression evaluator
Includes tests and help text.
2015-09-17 14:23:19 +02:00
Matthias Kuhn
25af142456 Add expression function help for $length 2015-09-17 11:08:29 +02:00
Juergen E. Fischer
e2816256f6 translation fix 2015-09-13 20:24:42 +02:00
Nyall Dawson
709c14391b Change expression help from free form html files to structured json
A new script then parses these json help files into the html help
contents, in a standardised manner. Previously, the function help
was a bunch of different formats and structures.

Now, a custom stylesheet can be applied (and later tweaked!) to
format these help. Eg, this commit colors variables and function
names in the syntax section for greater readability.
2015-09-02 14:22:50 +10:00