Question

Get fieldname from table to use in transformer

  • 4 December 2012
  • 2 replies
  • 12 views

Badge +1
  • Participant
  • 8 replies
I would like to get a  fieldname from a lookup table to use in transformer. I have an oracle table that I use for exporting data from SDE to dgn that holds things like igds_text_size, igds_cell_name etc. I use feauremerger with the layernames to match it to the layers to give all the features in a layer a standard set of values. This allows the attributes to be easily set and stored in an oracle table.

 

 

The  problem I run up against is I can't figure out how to set up which field to use for the text label. I have a field call TEXT_FIELD and I want each layer to use a different field from it's table as the label field.  I want to use labelPointReplacer to look at the table and use the field of the value in the TEXT_FIELD.

 

 

So for example for the layer address points I want it to use the field ADDRESS_LABEL and for Roads I want it to use the field STREET. I have those listed in the TEXT_FIELD but it just labels them with the text "STREET" and "ADDRESS_LABEL"

 

 

Ideally I would like some of them to be more complex but allow me to add the label string in the table  similar to something like:

 

 "GENPLAN:"  & [GENPLAN] & "- SECTION " & [SECTION_NO]

 

 

Any suggestions?

2 replies

Badge +3
Hi Mel,

 

 

You say in your post ...

 

 

>> So for example for the layer address points I want it to use the field ADDRESS_LABEL and for Roads I want it to use the field STREET. I have those listed in the TEXT_FIELD but it just labels them with the text "STREET" and "ADDRESS_LABEL"

 

 

What I think you can do is run your data through an AttributeExploder - this will create attribute name/value pairs as _attr_name and _attr_value for every attribute in your data schema.  What you can then do is a TESTER where:

 

TEXT_FIELD = _attr_name

 

Where this is true, your label value is the value contained in _attr_value

 

 

- you will probabaly also need to set "keep Attributes = Yes" on the AttributeExploder so you can do the test.

 

 

Hope this helps

 

 

Regards

 

Mike
Badge
Hi, I've tried to do a lot of this, and have had varying degrees of success. And to be honest it worked better in older version of FME rather than the new one.

 

The old method I used was the create an attribute inside a custom transformer, then use an attribute setter (exposing it's source attribute field) to set that temporary attribute with the value of some other attribute. You then use the temporary attibute to work with throught the custom transformer. This worked well in older versions where the attribute where you the exposed field wasn't requesting multiple inputs, only the one. It then made your custom transformer look like a proper FME one.

 

I haven't found a good solution yet for the latest version of FME, I think they've made things a bit limited both with the parameter fetcher and the attribute setter. I keep copying older versions into my workspace to get the desired effect.

 

I agree that having a transformer that let's you select the NAME of an attribute as opposed to it's value would be of great use and you would be able to develop nice looking custom transformers that way. Of course the new version of FME has lot's of nice little fesatures and there could be a work around that they haven't mentioned...?

Reply