Solved

TestFilter Conditional Statements

  • 25 November 2019
  • 6 replies
  • 28 views

Badge

Hello everyone,

I have a workspace where I'm trying to extract the two different 'styles' out of two attributes. In both attributes there are some strings that have 9 values, and some that have 11. I tried to use a TestFilter to extract these four separate styles into their own output. I've attached a photo of the statements I used. One problem I was noticing was that there was no attributes being cached at one of the outputs, even though the prior transformer output had the attributes present. Inspecting some of the cached features seems to be misleading, and sometimes shows missing values.

Could someone tell me what I'm doing wrong?

I can attach the workspace if needed.

Thanks,

Reid

icon

Best answer by bwn 25 November 2019, 18:54

View original

6 replies

Userlevel 3
Badge +13

Hi @reidm35 Yes, please attach a sample workspace. Thanks!

Badge

@danatsafe

Here is an example workspace. Let me know if you have any questions.

FME_Community_Example_P1328_RM_112219.fmw

Badge +3

I'm not sure if this is what you want TestFilter to do, however TestFilter will evaluate each conditional statement only on features that that have not yet tested True to any previous condition. It doesn't test each condition independently of the other conditions. So anything with GRID_ID_Start=9 chars long and GRID_ID_End=11 chars long will output features on Port "Start_=9" first, but it won't re-output them on Port "End_=11" because they were already found to be True in a previous condition and output on the earlier Port and hence won't appear in any later Ports. You may instead want to use conditions that use all possible unique combinations of Start and End like "@StringLength(@Value(GRID_ID_Start))=9 AND @StringLength(@Value(GRID_ID_End))=9" to Port "StartEnd0909", and "@StringLength(@Value(GRID_ID_Start))=9 AND @StringLength(@Value(GRID_ID_End))=11" to Port "StartEnd0911" etc.

Userlevel 2
Badge +12

If I understand what you are trying to do, I would use an AttributeCreator, creating:

Start_ as @StringLength(@Value(GRID_ID_Start))

End_ as @StringLength(@Value(GRID_ID_End))

This will add the two attributes to the features.

Hope this helps.

Badge

I'm not sure if this is what you want TestFilter to do, however TestFilter will evaluate each conditional statement only on features that that have not yet tested True to any previous condition. It doesn't test each condition independently of the other conditions. So anything with GRID_ID_Start=9 chars long and GRID_ID_End=11 chars long will output features on Port "Start_=9" first, but it won't re-output them on Port "End_=11" because they were already found to be True in a previous condition and output on the earlier Port and hence won't appear in any later Ports. You may instead want to use conditions that use all possible unique combinations of Start and End like "@StringLength(@Value(GRID_ID_Start))=9 AND @StringLength(@Value(GRID_ID_End))=9" to Port "StartEnd0909", and "@StringLength(@Value(GRID_ID_Start))=9 AND @StringLength(@Value(GRID_ID_End))=11" to Port "StartEnd0911" etc.

@bwn Thanks! Although this is a bit more complicated than I'm looking for. I just want to be able to split the GRID_ID_Start into the two styles and the GRID_ID_End into the two styles, and have four attributes. Like below. After this transformer the 11 value and 9 value strings need to be formatted in different ways and thus they need to be their own attribute for the start and end. Let me know what you think.

Badge +3

I'm not sure if this is what you want TestFilter to do, however TestFilter will evaluate each conditional statement only on features that that have not yet tested True to any previous condition. It doesn't test each condition independently of the other conditions. So anything with GRID_ID_Start=9 chars long and GRID_ID_End=11 chars long will output features on Port "Start_=9" first, but it won't re-output them on Port "End_=11" because they were already found to be True in a previous condition and output on the earlier Port and hence won't appear in any later Ports. You may instead want to use conditions that use all possible unique combinations of Start and End like "@StringLength(@Value(GRID_ID_Start))=9 AND @StringLength(@Value(GRID_ID_End))=9" to Port "StartEnd0909", and "@StringLength(@Value(GRID_ID_Start))=9 AND @StringLength(@Value(GRID_ID_End))=11" to Port "StartEnd0911" etc.

If the Attributes are to be handled separately then probably the best bet is to create 2 different TestFilters. One that will create 2 ports for the Start attribute number of characters. The 2nd TestFilter for the End attribute number of characters. Then manipulate the outputs of these 2 TestFilters independently to reformat the Start ID and the End ID respectively

Reply