Question

Settings User Parameters and Testing with Multiple Choice

  • 12 December 2014
  • 5 replies
  • 16 views

Badge +4
Hello!

 

 

My goal is to enable a FME user to select certain trajectories of waterways, on basis of attribute values, prior to executing the Workspace for the selected trajectories.

 

 

I accomplished to define a User Parameter that has as type "Choice (Multiple)". By importing the input file I could also select all the (unique) attribute values to take them into account as a valid choice.

 

 

Using a Tester I make a simple Test Clause to select the trajectory by setting it equal to the User Parameter. 

 

 

If I now select a single trajectory, the Workspace is successfully executed. If I however select multiple trajectories as User Parameter, no trajectories will pass the Test Clause and the FME Workspace will not be executed accordingly.

 

 

My guess is that the User Parameter stores the trajectories as a list, and that the Test Clause for some reason is not selecting the trajectories individually but attempts to find trajectories equal to the the list of trajectories. 

 

 

Does anyone have an idea how to solve this problem?

 

 

Kind regards,

 

 

Jochgem

 

 

 

5 replies

Badge +3
Hi Jochgem (not Jochem?)

 

 

 

You can test this by making one multiparameter and reading it with a paramaterefetcher (use dummy Cretor to link parameterfetcher to) and inspect it.

 

 

 

It stores it as a space delimitted string:

 

b c d

 

 

When there is a space in one or more choices it wil store this with double quotes: 

 

b c d "ggf  g" "aa bb dd"

 

 

So you can parse it or use splitter or what ever.
Badge +4
Thank you very much! This is very helpful!
Userlevel 2
Badge +17
Hi Jochgem,

 

 

As Gio mentioned, multiple choices will be stored as a string with space-separated format.

 

If any choice string doesn't contain whitespace, the AttributeSplitter (set delimiter to a whitespace) can be used easily to populate the choices into a list attribute.

 

Otherwise, however, it cannot be used since it will split a choice string at a whitespace within itself.

 

In such a case, I would use a TclCaller with a script like this.

 

-----

 

proc choicesToList {} {

 

    global FME_MacroValues

 

    set i 0

 

    foreach choice $FME_MacroValues(MULTI_CHOICE) {

 

        FME_SetAttribute "_list{$i}" $choice

 

        incr i

 

    }

 

}

 

-----

 

FYI.

 

Takashi
Badge +4
Thank you!
Badge +4
Thanks Gio and Takashi!

 

 

I incorporated the solution, using a dummy creator, a parameter fetcher, an attributesplitter and a feature merger. 

 

 

Cheers, Jochgem

Reply