A couple of year’s ago I wrote an article about ‘conditional processing’ in FME, and when to use the different filtering and mapping transformers. Looking back it seems a bit long-winded and complicated (sorry) and so I wanted to write this short post to simplify matters.
Basically I want to describe when to use the Tester, TestFilter, and AttributeFilter. I figure I can do that using some simple examples.
The Tester transformer is for simple Yes/No decisions, for example:
- “Would you like a beer?”
- “Are you 18 years or older?”
- “Is that road a primary road?”
These tests can be combined as well, within a single Tester, for example:
- “Would you like a beer AND are you 18 years or older?”
They can be quite complex too, in what we call a composite test, for example:
- “Would you like a beer AND (are you 18 years or older OR (do you live in the US AND are you 21 years or older))”?
…but each component is still a simple Yes/No test. The order of the conditions is only important when you do a composite test (and not always then).
The AttributeFilter is best for testing many values for a single attribute, for example:
- “Is your favourite beer Amber, Bitter, Lager, Pale, or Stout?”
- “Is that road a Primary Road, Secondary, Residential, Private, or Other?”
You wouldn’t do combination tests here (for example, a road can’t be both Primary and Secondary) and so the order of the tests is not important.
The TestFilter is best for filtering a feature by a set of cascading conditions, for example:
To play in the FME golf tournament you must pass one of these conditions (similar to the Masters qualification rules):
- “Are you the current champion?”
- “Are you a previous champion?”
- “Have you won another tournament in the last 5 years?”
- “Were you in the top 16 in last year’s FME tournament?”
- “Are you in the top-30 worldwide rankings?”
It’s a set of cascading tests, because if you are the current FME golf champion, you qualify at the top of the list. You don’t need to be tested against any other criteria. So here the test order is important.
Like the Tester, each test can be a combination of conditions, for example:
- “Are you in the top-30 worldwide rankings OR are you in the top-10 national rankings”
If the above seems familiar, well it’s an expanded version of some info in the FME training course.
I hope you find this a useful reference,
Mark IrelandMark, aka iMark, is the FME Evangelist (est. 2004) and has a passion for FME Training. He likes being able to help people understand and use technology in new and interesting ways. One of his other passions is football (aka. Soccer). He likes both technology and soccer so much that he wrote an article about the two together! Who would’ve thought? (Answer: iMark)