Skip to main content

Hello, 

I am quite new to FME and I am curious to know if there is a way to change the reader(s)/writer(s) using an interactive prompt box.

To be more specific, in my projects I have 3 readers:

ca/sacramento/address

ca/sacramento/roads

ca/sacramento/county

Each time I go to another county, I delete the readers and bring the new ones in:

tx/wise/address

tx/wise/roads

tx/wise/county

I would like to make a variable %path% which should get a value from the prompt box (or command line) so in the end I have a general fme template which I can use by only changing the %path% once.

In this way, maybe I cand run the program from the comand line, specifying the two parameters (state, county) and just let it run

 

Hi,

 

 

one solution could be to publish a parameter BASE_PATH containing e.g. "tx/wise" or "ca/sacramento".

 

 

You could then create three private scripted parameters that use BASE_PATH to construct the full input path, which you then link to the readers.

 

 

Python scripted parameter example:

 

 

base = FME_MacroValuesr"BASE_PATH"]

 

return base + "/address.shp"

 

 

Given BASE_PATH = "tx/wise", it would return "tx/wise/address.shp"

 

 

Hope this gives you enough to go on.

 

 

David
Hi,

 

 

There should be several approaches. Another idea: Create another workspace like Creator -> AttributeCreator -> WorkspaceRunnner. In the workspace, define a published parameter to select a directory path e.g. C:\\...\\tx\\wise, C:\\...\\ca\\acramento... Using AttributeCreator, create 3 source file paths based on the parameter. Then, through WorkspaceRunnder, you can pass those paths to parameters of the original workspace and run it.

 

You don't need to touch the original workspace.

 

Takashi
Even easier :-)

 

 

 

 

David
It's really easy!

Hello all,

Ok, thank you. I am going to try it out now. The main goal is to be able to run it in windows cmd.exe. 

Thanks for the support.


David.

I see your point, but I still do not see which type can prompt for the STATE, CITY and so on. Whilst reading the many tutorials, I think I am not quite sure how to create the published parameter (aka: to configure the Add/Edit Prameter box)

Where I want to end up, is to forward the values of those placeholders form the command line:

--[parameter_name] [parameter_value] e.g. --state ca

I know FME's Published Parameters can do this, I am just not quite sure..how


Hi,

 

 

Here is a detailed documentation: FME Workbench > About Published and Private Parameters

 

 

Takashi

Hi Takashi,

Yes, I saw the documentation but it seemed slightly poor in actually giving an example on how to set up Add/Edit Prameter box for a command line user input. 

There many types there, I always read documentation before asking, but I got stuck in the numerous attempts I had in testing it out. I am sure it will all work out in the end. Many thanks for the support


Hi,

 

 

In fact, only 'Name' is essential for a command line parameter configuration. Other settings are used to configure user input rules when executing the workspace via FME Workbench.   > fme workspacename.fmw --STATE ca   For this command line, creating a published parameter named 'SATE' i.e. setting 'STATE' to 'Name' on the 'Add/Edit Parameter' dialog box is the only requirement. Other settings are not related to the command line configuration. Even if you select 'Float' for 'Type', you can pass a character string (e.g. 'ca') to the workspace through the command line.

 

However, of course the settings had better be suitable for the workspace processing. For example, if the value of 'STATE' will be treated as a character string in the workspace, setting 'Text' or 'Choice' as 'Type' would be preferable.

 

Takashi

Hi Takashi,

Thank you. Now it makes perfect sense and you made things clear so I can continue the project. 

Many thanks to all,


Hello again, 

I am 95% ok with the project, there is just one small detail that I cannot figure out, 

All the published params work fine, exept one, where I use several published params in anoter published parameter:

C:\\usa\\test_data\\$(st_cd)_$(st_name)\\$(st_cd)$(ct_cd)_$(ct)_view\\overview_$(st_cd)$(ct_cd)_area.shp

The variables are declared in the publshed params section. They work for other processes, but not for this final one. The only exception is (maybe) that here i use a concat format "$(st_cd)$(ct_cd)_$(ct)_view">

Do you know of an operator that can show me the output of C:\\usa\\test_data\\$(st_cd)_$(st_name)\\$(st_cd)$(ct_cd)_$(ct)_view\\overview_$(st_cd)$(ct_cd)_area.shp?

I would like to debug this and to see what it puts in there and I could not find an operator similar to print (or data::dumper) in programming


Hi again,

 

 

a probable reason of the problem is the order of parameter definitions. Try moving st_cd, st_name, ct_cd and ct definitions to upper location of the file path parameter definition on the Navigator window. You can arrange the order by dragging the node or selecting shortcut menu - Move Up / Down.

 

Hope this helps.

 

 

Takashi
Alternatively, you may convert the file path parameter to a Private Parameter if the definition is unchangeable.

Ok, will try it out now. But the forst suggestion did not work.

Is there a way to see with what values does it replace the $variables in the output?


How about outputting parameter values to the Log window by ParameterFetcher + Logger?

Ok, I know the error; The path is constructed correctly, and the error is:

During translation, some features were read that did not match a reader feature type in the workspace. This can happen if the reader dataset is changed, or a reader feature type removed or renamed.

 

 

Ok, the problem can be that the reader changes based on the published parameteres every time. I do not know how to set a dummy reader. What I did is to add a shapefile and then edit its source by link-ing it to a published parameter where I added as a source $variables. It seems this does not work. 

a bit of log file:

Reading source feature # 45000 2013-05-27 16:15:09|   1.8|  0.0|INFORM|Emptying factory pipeline 2013-05-27 16:15:09|   1.8|  0.0|STATS |Unexpected Input Remover(TestFactory): Tested 45771 input feature(s) -- 0 feature(s) passed and 45771 feature(s) failed
Hi,

 

 

to solve that error, consider using 'Merge Feature Type' option of the reader. Ken's answer to 'Variable database feature reader' may be helpful.

 

And, if you need to continue discussing about this problem, feel free to post as a new question 🙂   Takashi

Mamma Mia!

that was so easy that I almost fell out of my mind. Thank you.

dunno why I always look for the more complicated way. Will post a new question soon. Now that my workspace is up and running I will try to enhance its usability.

 

Kind regards to all 

Reply