Skip to main content
Solved

Conditional Feature Writing Based on Multiple Readers with ID Filtering

  • October 28, 2024
  • 6 replies
  • 43 views

jugoslaviaa
Enthusiast
Forum|alt.badge.img+6

I have a workflow involving three readers (Reader 1, Reader 2, and Reader 3), and I need help setting up conditional logic based on feature counts for a given ID.

Here's what I'm trying to achieve:

  1. All three readers are filtered by the same ID.

  2. Condition 1:

    • If both Reader 1 and Reader 2 have at least one feature for the given ID, then do nothing—no features should be written to the writer.
  3. Condition 2:

    • If Reader 1 has at least one feature, but Reader 2 has zero features for the given ID, then:
      • Write the feature from Reader 3 that matches the given ID to the writer.

I'm looking for the best way to implement this logic in FME. 
 

Thanks for any advice or examples!

Best answer by jugoslaviaa

@nielsgerrits 

Thanks for the workbench! I need a bit of guidance on adjusting it for my specific requirements.

In my case, the ID is set as a user parameter, so all three readers (Reader 1, Reader 2, and Reader 3) will be filtered by this ID from the start. Sometimes, Reader 2 may have zero features simply because it doesn't contain any data with the specified ID and then I would like to copy the feature from Reader 3 with same id 

View original
Did this help you find an answer to your question?

6 replies

nielsgerrits
VIP

One way to do this is to use a FeatureMerger to determine if a feature in 1 is also in 2. Then use that result and a second FeatureMerger to get all features from 3 that are in 1 but not in 2.

The first FeatureMerger can also be a ChangeDetector.

Sample attached.


jugoslaviaa
Enthusiast
Forum|alt.badge.img+6
  • Author
  • Enthusiast
  • Best Answer
  • October 28, 2024

@nielsgerrits 

Thanks for the workbench! I need a bit of guidance on adjusting it for my specific requirements.

In my case, the ID is set as a user parameter, so all three readers (Reader 1, Reader 2, and Reader 3) will be filtered by this ID from the start. Sometimes, Reader 2 may have zero features simply because it doesn't contain any data with the specified ID and then I would like to copy the feature from Reader 3 with same id 


nielsgerrits
VIP

I think you can connect these readers to the connections and they will just work?


jugoslaviaa
Enthusiast
Forum|alt.badge.img+6
  • Author
  • Enthusiast
  • October 28, 2024

@nielsgerrits It does not work because one of the reads has no feature, so it won't be merged with a feature.


jugoslaviaa
Enthusiast
Forum|alt.badge.img+6
  • Author
  • Enthusiast
  • October 28, 2024

@nielsgerrits I am very sorry. I messed up the port. It works!! Thanks a lot


nielsgerrits
VIP

Cheers :)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings