Question

Fanout on attribute after generic reader


Userlevel 1
Badge +10

I have a workspace that reads a table and then outputs a map per polygon feature using a fanout on the writer. This relies on there being an attribute called Name with unique values within the source table.

 

 

I'm trying to make this a bit more robust and catering for situations where an attribute called Name might not exist (e.g. it's actually NAME or name)

 

 

I can use a Schema_mapper to rename NAME and name to Name but this doesn't cater for the situations where the unique field is called _name or even ID :-)

 

 

What I'd really like to be able to do is get the user to type the field name to be used to fanout when selecting the source input but I can't figure out if this is possible. Any ideas?

11 replies

Userlevel 4
Hi,

 

 

I suspect that's not possible without using more than one workspace.

 

 

David
Userlevel 4
Just an idea: have you tried using something like an AttributeRenamer to read the published parameter into an attribute? You could then "hard code" this attribute into the fanout settings.

 

 

David
Userlevel 1
Badge +10
I know you can rename a specified attribute to a parameter value, but I want to choose the attribute to rename based on the parameter value which I can't see is possible.

 

 

I suspect the easiest solution in this instance might be to get the user to access the schema and add the relevant field name in there to be remapped.
Userlevel 2
Badge +17
Hi,

 

 

How about creating new attribute with the AttributeCreator? Attribute Name: _fanout_attribute Value: @Value($(ATTR)) "ATTR" is name of a parameter whose value should be selected by user.

 

 

Takashi
Userlevel 1
Badge +10
Yes, that works. I had tried that earlier but as the workspace at that time had some user_attributes associated with the reader typing in the name set the parameter to an attributevalue rather than a string which then caused the attributecreator to fail.
Userlevel 4
Hi,

 

 

Just to clarify, my original suggestion was identical to Takashi's, but I guess he made it clearer :-)

 

 

David
Userlevel 1
Badge +10
I was getting hung up on the AttributeRenamer bit when actually I wanted an AttributeCreator. :-)

 

 

(I'm still using 2013 so it may be possible in 2014 to reference a parameter within the renamer?)
Userlevel 4
If FME 2013, you can actually use the AttributeRenamer to:
  • Rename attributes(!)
  • Create attributes
  • Remove attributes
Example:

 

 

 

 

Also, you can reference published and private parameters inside, as in the example above.

 

 

David
Userlevel 1
Badge +10
Ah, never appreciated you could just leave the old attribute blank like that to create a new attribute. I'll give you a thumbs up too :) , although not sure that'll work as i'm having to write this from my phone as linked images on fmepedia crash my browser when I'm logged in. The joys of work computers.
Userlevel 2
Badge +17
I've never used the AttributeRenamer for creating or removing attributes. The functionality seems to be effective in some cases.

 

Thanks for the clarification, David.
Userlevel 4
Badge +13
This was published by the FME Evangelist already at the start of 2012.

 

http://blog.safe.com/2012/01/fmeevangelist96/

Reply