Skip to content

Commit c1bf78e

Browse files
committed
Merge pull request #587 from nyalldawson/new_functions
New functions
2 parents a14adc4 + 23a7ebf commit c1bf78e

15 files changed

+355
-5
lines changed

resources/function_help/abs-en_US

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<h3>abs() function</h3>
2+
Returns the absolute value of a number.<br>
3+
4+
5+
<h4>Syntax</h4>
6+
abs(<i>value</i>)<br>
7+
8+
<h4>Arguments</h4>
9+
<code>value</code> - a number.<br>
10+
11+
<h4>Example</h4>
12+
<code>abs(-2) &rarr; 2</code><br>

resources/function_help/ceil-en_US

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h3>Function ceil()</h3>
2+
Rounds a number upwards.
3+
4+
<h4>Syntax</h4>
5+
<code>ceil(value)</code><br>
6+
7+
<h4>Arguments</h4>
8+
<code>value</code> - a number.
9+
<br>
10+
11+
<h4>Example</h4>
12+
<!-- Show example of function.-->
13+
<code>ceil(4.9) &rarr; 5</code><br>
14+
<code>ceil(-4.9) &rarr; -4</code><br>

resources/function_help/floor-en_US

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h3>Function floor()</h3>
2+
Rounds a number downwards.
3+
4+
<h4>Syntax</h4>
5+
<code>floor(value)</code><br>
6+
7+
<h4>Arguments</h4>
8+
<code>value</code> - a number.
9+
<br>
10+
11+
<h4>Example</h4>
12+
<!-- Show example of function.-->
13+
<code>floor(4.9) &rarr; 4</code><br>
14+
<code>floor(-4.9) &rarr; -5</code><br>

resources/function_help/log-en_US

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This function takes two arguments.
66
<code>log(base, value)</code><br>
77

88
<h4>Arguments</h4>
9-
<code>base</code> - any positive number.
9+
<code>base</code> - any positive number.<br>
1010
<code>value</code> - any positive number.
1111
<br>
1212

resources/function_help/max-en_US

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h3>max() function</h3>
2+
Returns the largest value in a set of values.
3+
4+
<h4>Syntax</h4>
5+
max(<i>value<i>[,<i>value</i>...])
6+
7+
<h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> value</i> &rarr; a number.<br>
10+
11+
<h4>Example</h4>
12+
<!-- Show example of function.-->
13+
max(2,10.2,5.5) &rarr; 10.2

resources/function_help/min-en_US

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h3>min() function</h3>
2+
Returns the smallest value in a set of values.
3+
4+
<h4>Syntax</h4>
5+
min(<i>value<i>[,<i>value</i>...])
6+
7+
<h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> value</i> &rarr; a number.<br>
10+
11+
<h4>Example</h4>
12+
<!-- Show example of function.-->
13+
min(20.5,10,6.2) &rarr; 6.2

resources/function_help/rand-en_US

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h3>rand() function</h3>
2+
Returns a random integer within the range specified by the minimum and
3+
maximum argument (inclusive).
4+
<br>
5+
This function takes two arguments.
6+
<h4>Syntax</h4>
7+
<code>rand(min, max)</code><br>
8+
9+
<h4>Arguments</h4>
10+
<code>min</code> - an integer representing the smallest possible random number desired.<br>
11+
<code>max</code> - an integer representing the largest possible random number desired.
12+
<br>
13+
14+
<h4>Example</h4>
15+
<!-- Show example of function.-->
16+
<code>rand(1, 10) &rarr; 8</code><br>

resources/function_help/randf-en_US

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h3>rand() function</h3>
2+
Returns a random float within the range specified by the minimum and
3+
maximum argument (inclusive).
4+
<br>
5+
This function takes two arguments.
6+
<h4>Syntax</h4>
7+
<code>randf(min, max)</code><br>
8+
9+
<h4>Arguments</h4>
10+
<code>min</code> - a float representing the smallest possible random number desired.<br>
11+
<code>max</code> - a float representing the largest possible random number desired.
12+
<br>
13+
14+
<h4>Example</h4>
15+
<!-- Show example of function.-->
16+
<code>randf(1, 10) &rarr; 4.59258286403147</code><br>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h3>regexp_substr() function</h3>
2+
Returns the portion of a string which matches a supplied regular expression.
3+
4+
<p><h4>Syntax</h4>
5+
regexp_substr(<i>string,regex</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> &rarr; is string. The input string.<br>
10+
<i> regex</i> &rarr; is string. The regular expression to match against. Backslash characters must be double escaped (eg "\\s" to match a white space character).<br>
11+
12+
<p><h4>Example</h4>
13+
<!-- Show example of function.-->
14+
regexp_substr('abc123','(\\d+)') &rarr; '123'</p>

resources/function_help/right-en_US

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Returns a substring that contains the <i>n</i> rightmost characters of the strin
77
<h4>Arguments</h4>
88
<code>string</code> - is string. The string.
99
<br>
10-
<code>length</code> - is int. The numbder of characters from the right to return.
10+
<code>length</code> - is int. The number of characters from the right to return.
1111

1212
<h4>Example</h4>
1313
<!-- Show example of function.-->
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h3>scale_linear() function</h3>
2+
Transforms a given value from an input domain to an output range using linear interpolation.
3+
4+
<p><h4>Syntax</h4>
5+
scale_linear(<i>val</i>,<i>domain_min</i>,<i>domain_max</i>,<i>range_min</i>,<i>range_max</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> val</i> &rarr; is a value in the input domain. The function will return a corresponding scaled value in the output range.<br>
10+
<i> domain_min, domain_max</i> &rarr; specify the input domain, the smallest and largest values the input <i>val</i> should take.<br>
11+
<i> range_min, range_max</i> &rarr; sepcify the output range, the smallest and largest values which should be output by the function.<br>
12+
13+
<h4>Example</h4>
14+
<!-- Show example of function.-->
15+
scale_linear(5,0,10,0,100) &rarr; 50<br>
16+
scale_linear(0.2,0,1,0,360) &rarr; 72 <i>(eg, scaling a value between 0 and 1 to an angle between 0 and 360)</i><br>
17+
scale_linear(1500,1000,10000,9,20) &rarr; 10.22 <i>(eg, scaling a population which varies between 1000 and 10000 to a font size between 9 and 20)</i><br>
18+
19+

resources/function_help/trim-en_US

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h3>trim() function</h3>
2+
Removes all leading and trailing whitespace (spaces, tabs, etc) from a string.
3+
4+
<p><h4>Syntax</h4>
5+
trim(<i>string</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> &rarr; is string. The string to trim.</p>
10+
11+
<p><h4>Example</h4>
12+
<!-- Show example of function.-->
13+
trim(' hello world ') &rarr; 'hello world'</p>

src/app/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ int main( int argc, char *argv[] )
294294
SetUnhandledExceptionFilter( qgisCrashDump );
295295
#endif
296296

297+
// initialize random number seed
298+
srand( time( NULL ) );
299+
297300
/////////////////////////////////////////////////////////////////
298301
// Command line options 'behaviour' flag setup
299302
////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)