Question

loop through features

  • 5 January 2017
  • 4 replies
  • 80 views

Hi,

I am quite new in FME and I have a bit of hard time with nested loop.

From a Tester transformer (Tester_2), some of my data could pass my stated condition and some couldn't. In the attributes of passed and failed data, there is a field that contains different values and some of which are identical in the both output date from Tester_2. The values are integers and the name of field is vegdekke_objectid.

What I want to do is to use the failed data and cross-check them, feature by feature, with the features of passed data based on the field value (vegdekke_objectid). In doing so, I was thinking to create a loop transformer by means of Custom Transformer and have a Tester transformer within the loop. The loop then would iterate and compare one feature at the time in the failed data with the features in the passed data. If no matching value is find for a feature in the failed data, then the feature is considered as the output of the loop transformer. Otherwise, the loop reads the next feature in the failed data and perform the same evaluation until it reads all features in the failed data.

One thing that you may notice from the wrokbench processes is that I created a new attribute based on the field value (vegdekke_objectid) of passed data and called it "nottobeselected". The idea is to compare the value in the loop in two different fields.

I tried the discribed methodological approach, but it seems I am missing or misunderstanding some parts in FME. I highly appreciate your help and thanks for the time you are spending.

Best regards


4 replies

Userlevel 4
Badge +25

I think a FeatureMerger would be a better way of approaching this. Use it in place of your custom transformer, put the Tester_2_Failed features in as Requestors and the others as Suppliers, then match on vegdekke_objectid / nottobeselected and then if I understand you correctly you'll want the NotMerged output.

Badge

Hi @bobakebi

I feel your struggle. When I started working with FME, it was quite a challenge to change my thinking to solve these kind of problems without using loops.

I think this problem can be solved by using the FeatureMerger. This transformer allows you to compare data from two input ports on one or more specific attributes.

In your case, you should link the failed port of the Tester to the Suppliers port of the FeatureMerger. The Passed port of the Tester should be linked with the Requestor port of the FeatureMerger.

In the FeatureMerger itself, you use the attribute vegdekke_objectid as a group by value and you should choose the option to process duplicate suppliers.

The output should be linked in the following way:

Merged and Not-merged should be connected if you want to use the features entering in the Requestor port afterwards.

You also keep the unreferenced output because this port contains those features that are input via the suppliers port but could not be linked / matched with a feature in the requestor port.

If something is not clear, please ask!

Good luck

Thank you jeroenstiers and redgeographics for the answers. As you explained, FeatureMerger was able to solve my problem. best regards

Badge

Thank you jeroenstiers and redgeographics for the answers. As you explained, FeatureMerger was able to solve my problem. best regards

Hi @bobakebi

 

I am glad we could help! Could you maybe close the question by clicking on the gear in the upper right corner? Thanks!

 

Reply