Couple of things come to mind:
- Python would likely be less easy to maintain, especially for other staff who have minimal programming knowledge
- Logic can be hidden from the main workflow via a custom transformer in order to maintain a level of neatness.
- Logic can be annotated with annotations and bookmarks to be easier to follow. Especially if best practices is followed.
- The basics of Python including the PythonCaller which I believe you'd be interested in: http://fmepedia.safe.com/articles/How_To/Python-and-FME-Basics
- Are you aware of the fat that multiple conditions can be encapulated within a single TestFilter so you may need less TestFilters in total? Annotations can encapsulate what is exactly going on in there. A summary annotation may be beneficial for maintenance purposes.
Hope this helps!
Hi Katherine,
Thanks for replaying :)
I am aware of all the points you mention and they are considered while setting up the ws (I try always to make my ws readble and clear).
Till now I have (but) 5 TestFilters, so its not a real great mess, I was just hoping to find a way to do it all in one transformer. Since my goal is eventually to create a custom transformer, the option of a custom transformer within another , is less favourable.
Itay
Hi Itay,
Well the TestFilter is an If-Then-Else construction.
IF the first test passes THEN the feature is output ELSE it goes to the next test. So each test should be carried out in sequence.
Also you could put multiple tests inside each IF part.
So I think you could put it inside one TestFilter, but then - if you want to set values - you would need an AttributeSetter for each output port.
I have a request in with the developers for an AttributeTestMapper transformer - that carries out multiple tests and maps features on that basis. Would that help here? If so let me know and I can add your contact info to the PR (PR#29409).
Hi Mark,
An AttributeTestMapper transformer sounds just like what I need, resulting in a cleaner canvas (replacing multiple TestFilters and AttributeRenamers/AttributeSetter)
I would appreciate adding my contact info to the PR.
Do you expect this new transformer to be added some time soon?
Cheers,
Itay
Welcome to my new best friend - InlineQuerier :)
Manitoba Mark has a great general writeup on how this works on his blog:
http://evangelism.safe.com/fmeevangelist97/
The SQLite version of SQL supports CASE statements that allow evaluation either on a single expression or on a series of expressions.
http://www.sqlite.org/lang_expr.html
So you could probably do something like:
SELECT Attribute4, CASE WHEN
Attribute1 LIKE 'GREEN'
AND Attribute2 LIKE 'PURPLE'
AND Attribute3 IS NOT NULL
THEN 'LOW' WHEN
Attribute1 LIKE 'ORANGE'
AND Attribute2 LIKE 'RED'
THEN 'MEDIUM' ELSE
'HIGH' END AS Status FROM MyTable
I haven't tested this specific statement, but I've used CASE in InlineQuerier extensively and it works well.
Hi Jason,
Thanks for the idea! it sure sounds like a neat solution and I will definitely look into it.
Itay
Casefilters and Testfilters are order dependent
So using them is very very dependent on the test you make.
Bolean compostion in a tester is a very handy way to do it.
This method allows for large and complex strings (but increasingly hard to read or decipher..) But you can test/evaluate the same attributevalues as many times as you wish.
Your example can only be done if you tst the same attributevalue twice as the first test is a subset of the second.
For the first is the same as:
if feature 1 has attribute x and attribute Y and ( attribute Z exists OR does not exists)
Testing for existence in expressions is problematic though..you would be " missing an operand"