FME Transformers: 2024.2
FME Transformers: 2024.2
Using Lists to Solve Problems
Challenge
You have linear street centerlines and, at each intersection point, you'd like to know which streets come together. The output should be a set of points, each with a single string attribute containing a comma-separated set of the street names.
Solution
Set up a workspace that routes all the street centerlines into an Intersector transformer. Adjust the parameters of the Intersector to supply a list name (for example, all_streets).
Let's assume that the input street lines had an attribute called NAME.
Now, among
other things, the Node output of the Intersector will have an unqualified
list on it called all_streets{}.NAME
. This
list will hold the names of all the streets that intersect at each particular
point (or Node) that is output.
To turn the list of NAMEs into a single string, add a ListConcatenator
transformer and run the NODE features into it. Then set up the ListConcatenator's
parameters so that it would put the contents of the all_streets{}.NAME
list together, separated by commas, into the destination attribute.
Route the output of the ListConcatenator to an output file, and ensure that the destination attribute was routed to an attribute in the output. After running the translation, you'd have the desired result.
Expose Elements
Note that you can also access the individual street names by "exposing"
some elements of your list: right-click on the attribute unqualified
list name (in our example, all_streets{}.NAME
)
and select Expose Elements.
In the Select List Elements dialog, enter the number of elements to expose. (The disadvantage to this approach is that you need to know ahead of time how many list elements you want to work with.)