Question

Can Global Variables be accessed as values in Transformers?

  • 27 September 2016
  • 3 replies
  • 58 views

Probably a newbie question....

 

I have a Workflow that will be used to import OSM data but with variable output options. These options are being defined in a Spreadsheet which I have FME reading in.

For example, one option is the highest category of settlement to include on this database (the categories are defined in house as 1-8 based on Population as 'settlement_category').

I have assigned the various options to a Global Variable but had expected to be able to use that in transformers such as Testers to allow for dynamic. We call this variable 'maxSettlementCategory'.

So the Tester would be something like:

(Left Value) (Operator) (Right Value)

 

settlement_category <= maxSettlementCategory

 

(Object Attribute) <= (Global Variable)

I cannot see how to do this without assigning the Global Variable to every object via an Attribute Manager and Variable Retriever, which all seems a little excessive. Am I missing something?


3 replies

Userlevel 2
Badge +17

Hi @bambography, I think there is no way to access a global variable in a transformer parameter directly. Use the VariableRetriever to assign the variable value to a feature attribute.

Hi @bambography, I think there is no way to access a global variable in a transformer parameter directly. Use the VariableRetriever to assign the variable value to a feature attribute.

Thank you takashi. I thought you might say that.

 

It is frustrating to add a whole list of attributes to the whole dataset only to allow us to perform one test later in the workflow, but never mind.

 

Thanks again.

 

 

Userlevel 4
Badge +25

The other way would be to use a FeatureMerger to merge the spreadsheet information onto the main features. Actually, a Joiner would be even better because then you wouldn't need to even read the spreadsheet into the workspace at all.

Global variables are OK in their place, but I'm not sure this is it. Like you say, it is a bit excessive, plus I'm always wary about using global variables because you then have to worry about the order of translations.

To paraphrase that old (old) joke: I had a problem and thought "I'll use global variables". Now I have two problems!

Reply