2013-06-23

FME String Functions

Recently I found the documentation about this subject > FME String Functions
These functions can be used in the Advanced Text Editor for the AttributeCreator etc. In some cases operating strings, using those effectively, we can reduce dramatically the number of transformers on the canvas.

Community > Attribute Trimmer
For example, just one AttributeCreator with the following expression as the value parameter for new attribute completes the job required in the question:
@ReplaceRegEx(@Value(AttrName),(.*)(...),\1)@Format(%03d,@Evaluate(@int(@ReplaceRegEx(@Value(AttrName),(.*)(...),\2))+1))

However, I don't know whether it's preferable or not from the viewpoint of maintainability. If using too many functions in a expression, it would become difficult to understand.
Use them moderately.

Attribute Name User Parameter

'Attribute Name' became available as a user parameter type since FME 2013, I was waiting for this functionality.
When using this parameter type, we have to be aware that the parameter value is not attribute value but attribute name. Those seem to be mixed up sometimes.
Community > Retrieving Parameter Attribute Values
Community > Should Attributes in Parameters be pointers?

When the parameter type is 'Attribute Name',
'$(PARAM_NAME)' represents the parameter value i.e. an attribute name,
'@Value($(PARAM_NAME))' represents the value which the attribute name refers to.
Let's keep this in mind, all is going well!

2013-06-12

FME 2013 SP2 has been released!

Many enhancements have been done. Especially, these improvements are very good for me!

Itemized FME 2013 SP2 "what's new" list 13451 - 13499
WorkspaceRunner: Fixed a problem with workspace names with Japanese characters (C76804 PR#45553)
FeatureMerger: Updated the FeatureMerger transformer to allow for multiple keys and expressions. Moved list-based functionality into a new ListBasedFeatureMerger transformer (RT#18286 RT#88882 RT#100659 RT#102469 C23344 C57978 C67125 PR#7243 PR#8014 PR#26611 PR#27410 PR#37809 PR#386689)


2013-06-08

Various Regular Expressions

Community > Replace value with a null
The point of this question is how to replace a character string like 'Today' or 'Day N' (N is a digit) with a null value so that only valid datetime strings formatted in "YYYY-mm-dd HH:MM:SS" will be preserved.
Of course, using the StringSearcher or the StringReplacer with a regular expression would be a solution. But there should be various approaches, which is more preferable?
Since there could be several patterns for non-datetime strings in such a case, we might need to prepare several regular expressions (and transformers) when filtering them out perfectly. However, for the datetime strings, we need only one expression. Even if new non-datetime string pattern appears in the future, we don't need to touch the expression.
So, I thought considering about a regular expression for the datetime strings is better rather than for non-datetime strings.

Addition:
The StringReplacer with the following settings can replace non-datetime string with a blank and also format a datetime string into 14 digits (YYYYmmddHHMMSS) simultaneously.
Text to Find: ^(([0-9]{4})-([0-9]{2})-([0-9]{2})\s([0-9]{2}):([0-9]{2}):([0-9]{2}))?(.*)$
Replacement Text: \2\3\4\5\6\7
Use Regular Expressions: yes

2013-06-03

How to create geometries from coordinates

Using the 2D / 3DPointReplacer, we can create a point from (x, y) / (x, y, z).
To create a line, I usually use the 2D / 3DPointAdder or the PointConnector after creating points.
If the created line is closed, these transformers generate a polygon.
If not (and if I need to create a polygon), also use the LineCloser.
=====
Note: In FME 2014, the 2D/3DPointReplacer and the 2D/3DPointAdder have been integrated into the VertexCreator transformer.
=====
2015-05-11: If you are going to create points based on coordinates (x, y) / (x, y, z) given by a CSV file or an Excel spreadsheet, you can also create them with the reader.
Look at the parameters dialog when adding the reader. If you set "x_coordinate", "y_coordinate" (and "z_coordinate") to the attribute types, the reader will create points based on the values.

























=====