The problem: I'm doing some simple geometric operations to extract some metadata about the roads of each community. Those operations include aggregating, finding a common midpoint and so on - basic stuff I've implemented and tested - but I've yet to find a dynamical way to add an attribute with the ID for that particular community.
For me, the next step is to iterate over each community, reading and treating data separately for each community polygon. I see I need to create custom transformers to do that. I'm happy with getting a little more hands-on with custom transformers - but I would appreciate a little guidelines on the way.
In my head the solution would look like this:
1) Read all polygons that define the community borders
2.0) For each polygon
2.1 - Use FeatureReader with that polygon as initiator
2.2 - Do my simple geometry stuff
2.3 - Assign the community ID of the initiator to all features of this community
3) - save to appropriate format
It irritates the heck out of me that step 2.3 seems to be beyond my grasp... using attribute(s) from the initiator of featureReader as basis to create new attributes on each feature being read seems to me to be a very intuitive thing to do. I guess I need to publish that relevant initiator-attribute as a parameter and use attributeCreator to grab that parameter and copy it.
Step 2.0 is certainly doable, but involves some steps I'm neither familar nor comforable with (yet). I use "blocking transformers", so my custom transformer needs to be both external and linked. And then there is the "black art" of defining the loop for my custom transformer. This was probably described extensively way back in 2006 when it was introduced, but today I have trouble finding a step-by-step guide describing what I should do and the pitfals to avoid. I'm not looking for recursive algorithms or fractal arts - I want to take one feature, do XYZ, then proceed to the next.
Of course I know that my problem is solvable without iteration. FME impresses me with the ability to read a huge bunch of roads, process them and spit it out. But my solution - where you only treat a subset of roads at a time - will be hugely more efficient.
Any hints on how I best should proceed? Links to looping-for-dummies? Or is there a non-looping solution that I should explore?