Parameter Condition Definition Dialog
In many transformers and writers, attribute values can be set conditionally - that is, different values are assigned based on whether or not specified conditions are met.
As shown here in an AttributeCreator transformer, if Conditional Value... appears on the context menu when setting a value, conditionals are available.
In the Parameter Condition Definition dialog, we define one or more Test Conditions and the value to assign if that condition is successful (passes).
Each Test Condition consists of one or more Test Clause(s), which evaluate values or expressions based on a wide range of available Operators and test types. The Test Clauses are connected with Logic - combinations of AND, OR, and NOT, with parentheses to define evaluation order.
If the first test (If) is not successful (fails), the next Test Condition is evaluated (Else If), and so on until no Test Conditions remain. If none of the Test Conditions are successful, the final (Else) value will be used.
Note that testing operations are lexical and not locale-aware.
Creating Test Clauses
Each clause is composed of a value to test, and the method of testing it. Depending on the type of test, at a minimum the clause will consist of a Left Value and an Operator. If the chosen Operator needs more information (for example, testing for an attribute that is greater than a certain value), a Right Value field is provided.
The Test Clauses are created in a table, and numbered from the top down.
Left Value |
Operator |
Right Value |
Mode* |
---|---|---|---|
The value or expression to test | The type of test to perform | The value for comparison, if required by the operator | Test the values in a specific manner |
Examples | |||
Latitude | > | 49.000001 | Automatic |
@Area() | In Range | (1,100) | Numeric |
SnackType | Like | Kebabs | Case Sensitive |
Traffic | Attribute Is Null | <Unused> | Automatic |
Count | Type Is | Integer | Automatic |
* Note that Mode is only available for individual tests when Comparison Mode is set to Specify Per Test.
Test Clause Operators
These are the Operators available for constructing test clauses. They may be used to test attribute values, constructed expressions, constants, and published parameters.
Note that (unless otherwise specified) most operators can be used with both numeric values and strings. Strings may be compared with the =, !=, <, >, <=, and >= operators, and are evaluated by their character codes, so A < B.
Operator |
Description |
Right Value Configuration |
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= | Equal to | Enter a value for comparison. | ||||||||||||||||
!= | Not Equal to | Enter a value for comparison. | ||||||||||||||||
< | Less than | Enter a value for comparison. | ||||||||||||||||
> | Greater than | Enter a value for comparison. | ||||||||||||||||
<= | Less than or equal to | Enter a value for comparison. | ||||||||||||||||
>= | Greater than or equal to | Enter a value for comparison. | ||||||||||||||||
In Range |
Tests if the value falls within the numeric range specified in set notation. Open-ended ranges may be defined by leaving either the lower or upper limit blank. |
Range values are separated by a comma and enclosed by brackets. Square brackets - [ ] - indicate inclusive limits (greater than or equal to, less than or equal to). Round brackets - ( ) - indicate exclusive limits (greater than, less than). Valid range examples: (1,9) Greater than 1 and less than 9 [1,9] Greater than or equal to 1 and less than or equal to 9 (1,9] Greater than 1 and less than or equal to 9 (1,) Greater than 1 [,9] Less than or equal to 9 Note This operator is not available when Mode is set to Case Sensitive or Case Insensitive, and those modes are not available when the operator is set to In Range.
|
||||||||||||||||
In | Tests if the value may be found in the provided list of possible values and ranges. |
Enter any combination of comma-separated strings, numeric values, and/or ranges (in the form of x-y). Valid configuration examples: 1,10,100 1-99 cat cat,dog,cats and dogs dogs,1-9,7 String ranges (for example, a-d) can also be specified. To test for values that contain a hyphen, enclose the value in quotation marks: "LL-27","LL-83". To test for values that contain either single (') or double (") quotes, enclose the value in the opposing quotes: "Duncan's Lake" or 'Say "Hello"'. |
||||||||||||||||
Like | Tests that the value matches a specified string pattern. |
Enter a string pattern. Wildcards are supported using the percentage symbol (%), rather than an asterisk (*). In Automatic mode, this operator is case insensitive. This operator is not available when Mode is set to Numeric. Example: If Right Value is %bc%: abcd: Passed bc: Failed |
||||||||||||||||
Contains | Tests that the Right Value occurs somewhere in the Left Value. |
Enter a value to test for. In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. Example: If Right Value is bc: abcd: Passed abde: Failed |
||||||||||||||||
Begins With | Tests that the Left Value string begins with the Right Value string. |
Enter the string to be tested against. In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. Example: If Right Value is Do: Dogs: Passed Cats: Failed |
||||||||||||||||
Ends With | Tests that the Left Value string ends with the Right Value string. |
Enter the string to be tested against. In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. Example: If Right Value is gs: Dogs: Passed Cats: Failed |
||||||||||||||||
Contains Regex | Tests that the value contains a string that matches a pattern described by a Regular Expression. |
Enter a Regular Expression. The Regular Expression Editor is available via the ellipsis (...) button, and may be used to construct and test expressions. The regex to test may represent a string to be found anywhere within the value, or may represent the entire value (by creating a regex long enough to represent the extent of the desired value). Example: If regex is \d (Any digit) cats: Failed 9: Passed cats82: Passed |
||||||||||||||||
Type Is |
Tests if the value is compatible with the chosen Type. You may test for multiple types by adding additional Test Clauses. |
Select the Type to test for.
|
||||||||||||||||
Encodable In | Tests if the value is encodable in the specified encoding without data loss. |
Select from a list of standard encodings. Sample encodings:
|
||||||||||||||||
Attribute has a value | Tests that the attribute has a value, and is not null, missing, or empty. | <Unused> | ||||||||||||||||
Attribute Is Null | Tests that the attribute has a null value. |
<Unused> |
||||||||||||||||
Attribute is Empty String | Tests that the value is an empty string. | <Unused> | ||||||||||||||||
Attribute is Missing | Tests that the attribute is absent on the feature | <Unused> |
Cached Values and Data-Aware Test Clauses
If Feature Caching is enabled, valid attribute values from upstream features can be viewed to complete test clauses.
As shown here in the Tester, if the Left Value has been set to an Attribute Value and the features have been cached, the context menu provides access to the values available in those features. If there are only a few choices, they will be presented in a sub-menu.
If there are a large number of choices, the values will be presented in a Select Value dialog, where the values may be sorted and searched with the Filter option.
Connecting Test Clauses: Logic
Multiple test clauses are connected with Logic, using AND, OR, and NOT in addition to parentheses to specify how the tests are evaluated to determine passing or failing.
Logic connectors can be edited by selecting options in the Logic column of the Test Clauses table, or may be edited directly using the Composite Expression parameter’s Edit button.
Example: Assigning multiple attribute values with Conditional Values
In this example, we will create one new attribute, and assign its value based on another value. The original data contains streets with two attributes. They are routed into an AttributeCreator.
In the parameters dialog, conditional values have been defined, indicated by 7 Possible Values. We can review them via the ellipsis button or the context menu.
Six Test Conditions have been created, assigning a code to the new attribute USE_CODE, based on the value of the existing attribute USE. If a USE value is found that does match any of these tests, it will receive the USE_CODE value UN.
The output features now have conditionally assigned values for the new attribute USE_CODE.