Skip to content

Commit

Permalink
Merge pull request #587 from nyalldawson/new_functions
Browse files Browse the repository at this point in the history
New functions
  • Loading branch information
NathanW2 committed May 12, 2013
2 parents a14adc4 + 23a7ebf commit c1bf78e
Show file tree
Hide file tree
Showing 15 changed files with 355 additions and 5 deletions.
12 changes: 12 additions & 0 deletions resources/function_help/abs-en_US
@@ -0,0 +1,12 @@
<h3>abs() function</h3>
Returns the absolute value of a number.<br>


<h4>Syntax</h4>
abs(<i>value</i>)<br>

<h4>Arguments</h4>
<code>value</code> - a number.<br>

<h4>Example</h4>
<code>abs(-2) &rarr; 2</code><br>
14 changes: 14 additions & 0 deletions resources/function_help/ceil-en_US
@@ -0,0 +1,14 @@
<h3>Function ceil()</h3>
Rounds a number upwards.

<h4>Syntax</h4>
<code>ceil(value)</code><br>

<h4>Arguments</h4>
<code>value</code> - a number.
<br>

<h4>Example</h4>
<!-- Show example of function.-->
<code>ceil(4.9) &rarr; 5</code><br>
<code>ceil(-4.9) &rarr; -4</code><br>
14 changes: 14 additions & 0 deletions resources/function_help/floor-en_US
@@ -0,0 +1,14 @@
<h3>Function floor()</h3>
Rounds a number downwards.

<h4>Syntax</h4>
<code>floor(value)</code><br>

<h4>Arguments</h4>
<code>value</code> - a number.
<br>

<h4>Example</h4>
<!-- Show example of function.-->
<code>floor(4.9) &rarr; 4</code><br>
<code>floor(-4.9) &rarr; -5</code><br>
2 changes: 1 addition & 1 deletion resources/function_help/log-en_US
Expand Up @@ -6,7 +6,7 @@ This function takes two arguments.
<code>log(base, value)</code><br>

<h4>Arguments</h4>
<code>base</code> - any positive number.
<code>base</code> - any positive number.<br>
<code>value</code> - any positive number.
<br>

Expand Down
13 changes: 13 additions & 0 deletions resources/function_help/max-en_US
@@ -0,0 +1,13 @@
<h3>max() function</h3>
Returns the largest value in a set of values.

<h4>Syntax</h4>
max(<i>value<i>[,<i>value</i>...])

<h4>Arguments</h4>
<!-- List args for functions here-->
<i> value</i> &rarr; a number.<br>

<h4>Example</h4>
<!-- Show example of function.-->
max(2,10.2,5.5) &rarr; 10.2
13 changes: 13 additions & 0 deletions resources/function_help/min-en_US
@@ -0,0 +1,13 @@
<h3>min() function</h3>
Returns the smallest value in a set of values.

<h4>Syntax</h4>
min(<i>value<i>[,<i>value</i>...])

<h4>Arguments</h4>
<!-- List args for functions here-->
<i> value</i> &rarr; a number.<br>

<h4>Example</h4>
<!-- Show example of function.-->
min(20.5,10,6.2) &rarr; 6.2
16 changes: 16 additions & 0 deletions resources/function_help/rand-en_US
@@ -0,0 +1,16 @@
<h3>rand() function</h3>
Returns a random integer within the range specified by the minimum and
maximum argument (inclusive).
<br>
This function takes two arguments.
<h4>Syntax</h4>
<code>rand(min, max)</code><br>

<h4>Arguments</h4>
<code>min</code> - an integer representing the smallest possible random number desired.<br>
<code>max</code> - an integer representing the largest possible random number desired.
<br>

<h4>Example</h4>
<!-- Show example of function.-->
<code>rand(1, 10) &rarr; 8</code><br>
16 changes: 16 additions & 0 deletions resources/function_help/randf-en_US
@@ -0,0 +1,16 @@
<h3>rand() function</h3>
Returns a random float within the range specified by the minimum and
maximum argument (inclusive).
<br>
This function takes two arguments.
<h4>Syntax</h4>
<code>randf(min, max)</code><br>

<h4>Arguments</h4>
<code>min</code> - a float representing the smallest possible random number desired.<br>
<code>max</code> - a float representing the largest possible random number desired.
<br>

<h4>Example</h4>
<!-- Show example of function.-->
<code>randf(1, 10) &rarr; 4.59258286403147</code><br>
14 changes: 14 additions & 0 deletions resources/function_help/regexp_substr-en_US
@@ -0,0 +1,14 @@
<h3>regexp_substr() function</h3>
Returns the portion of a string which matches a supplied regular expression.

<p><h4>Syntax</h4>
regexp_substr(<i>string,regex</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> &rarr; is string. The input string.<br>
<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>

<p><h4>Example</h4>
<!-- Show example of function.-->
regexp_substr('abc123','(\\d+)') &rarr; '123'</p>
2 changes: 1 addition & 1 deletion resources/function_help/right-en_US
Expand Up @@ -7,7 +7,7 @@ Returns a substring that contains the <i>n</i> rightmost characters of the strin
<h4>Arguments</h4>
<code>string</code> - is string. The string.
<br>
<code>length</code> - is int. The numbder of characters from the right to return.
<code>length</code> - is int. The number of characters from the right to return.

<h4>Example</h4>
<!-- Show example of function.-->
Expand Down
19 changes: 19 additions & 0 deletions resources/function_help/scale_linear-en_US
@@ -0,0 +1,19 @@
<h3>scale_linear() function</h3>
Transforms a given value from an input domain to an output range using linear interpolation.

<p><h4>Syntax</h4>
scale_linear(<i>val</i>,<i>domain_min</i>,<i>domain_max</i>,<i>range_min</i>,<i>range_max</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> val</i> &rarr; is a value in the input domain. The function will return a corresponding scaled value in the output range.<br>
<i> domain_min, domain_max</i> &rarr; specify the input domain, the smallest and largest values the input <i>val</i> should take.<br>
<i> range_min, range_max</i> &rarr; sepcify the output range, the smallest and largest values which should be output by the function.<br>

<h4>Example</h4>
<!-- Show example of function.-->
scale_linear(5,0,10,0,100) &rarr; 50<br>
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>
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>


13 changes: 13 additions & 0 deletions resources/function_help/trim-en_US
@@ -0,0 +1,13 @@
<h3>trim() function</h3>
Removes all leading and trailing whitespace (spaces, tabs, etc) from a string.

<p><h4>Syntax</h4>
trim(<i>string</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> &rarr; is string. The string to trim.</p>

<p><h4>Example</h4>
<!-- Show example of function.-->
trim(' hello world ') &rarr; 'hello world'</p>
3 changes: 3 additions & 0 deletions src/app/main.cpp
Expand Up @@ -294,6 +294,9 @@ int main( int argc, char *argv[] )
SetUnhandledExceptionFilter( qgisCrashDump );
#endif

// initialize random number seed
srand( time( NULL ) );

/////////////////////////////////////////////////////////////////
// Command line options 'behaviour' flag setup
////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c1bf78e

Please sign in to comment.