I am using LineJoiner to merger street segments together based on the attribute STREET. Each segment contains STREET, FROM_STREET and TO_STREET and a SEQUENCE. I have ordered them by Sequence before the LineJoiner transformer and now I want to extract the FROM_STREET and TO_STREET for the merged segments. I renamed ROAD{0}.FROM_STREET to FROM_STREET, and that works fine. But how do I tell the List Element Selection to be the last element? It won't take -1 or any non-number or _element_count. Is there another way to do this? Ideally I would like it to be something simple like ROAD{MAX}.TO_STREET.
I'd probably use a ListIndexer here - it pushes all the list items at index 0 or -1 into attributes, with an optional prefix.
You can use the ListElementCounter to retrieve the index number of the last entry in a list.
Alternatively, FME Functions might also be used in an expression setting to the Value column of AttributeCreator, like this.
@Value(ROAD{@Evaluate(@NumElements(ROAD{})-1)}.TO_STREET)
The FMEFunctionCaller can also be used to perform the expression.
I'd probably use a ListIndexer here - it pushes all the list items at index 0 or -1 into attributes, with an optional prefix.
Agreed. I'd stick with the above method to get the first one. But BEFORE renaming the 0th element, I'd do the ListIndexer with -1 (which is the last element). If you log or inspect you'll see why -- doing the ListIndexer first will get you the TO_STREET and the FROM_STREET but from the last element of the list. Following that with the Renamer to get you the FROM_STREET of the 0th will overwrite the other value that was there and get you what you want.