FME Transformers: 2024.2

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.

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.