Any idea .. Thanks
Any idea .. Thanks
You can use the LineJoiner to create a list attribute which contains all the attributes of connected lines, and also use the PathSplitter to restore the original lines, like this.
The point is to connect the lines as a Path object.
And then, you will have to add some list operation to accomplish the purpose, between the two transformers or after the PathSplitter.
"how to" depends on your requirement, but I'm still unclear the requirement, so cannot provide a concrete way.
Could you please illustrate your requirement more strictly?
Takashi
"attr1" of line1 has value "5",
"attr1" of line2 has value "10",
"attr1" of line3 has value "0".
In this example, do you need to give "10" (the maximum value among all the "attr1" of connected lines) to every line?
If so, the ListRangeExtractor in this data flow might help you.
Loop in a custom transformer might also be a solution, but I think list operation is easier in this case.
In a set of 3 lines that are consecutively arranged,
- if the "attr1" of the 2nd line is "null", replace it with max value of "attr1" of the 1st line and "attr1" of the 3rd line.
- otherwise (i.e. if "attr1" of the 2nd line is not "null"), do nothing.
Do it for every set of adjoining 3 lines sequentially from the beginning to the end, in the connected lines.
0 is considered as "null".
Therefore,
"3,0,1,2,4" should become "3,3,1,2,4",
"1,0,3,0,2" should become "1,3,3,3,2".
Is it correct?
If so, in these example?
"0,1,0,2,<null>" => "0,1,2,2,<null>" (not change first/last "null"?)
"1,<null>,<null>,<null>,2" => "1,1,1,2,2" (real <null> is less than any value?)
"0,0,0,1,2" => "0,0,1,1,2"?
"1,0,0,0,0" => "1,1,1,1,0"?
For 0,0,0,1,2 should give 1,1,1,1,2 and the second should give 1,1,1,1,1 (I do want to ha ve a zéro or null) .. thanks
This data flow would be a solution.
The Counter adds 1-based sequential number to the lines for each group (_index).
The StatisticsCaluclator counts the number of lines in a group (_count).
The NullAttributeMapper replaces <null>, <empty>, <missing> "attr1" with 0.
The AttributeCreator replaces 0 "attr1" with:
- "attr1" of the subsequent line if the line is the first one in a group,
- "attr1" of the prior line if the line is the last one in a group,
- otherwise, the maximum "attr1" in prior and subsequent lines.
But it doesn't support the case like "0,0,0,1,2" (i.e. there are consecutive zeros in the first part). To resolve such a case, add this data flow.
The Tester and the Sampler selects the first feature having non-zero "attr1" for each group.
The FeatureMerger merges the first non-zero value to every feature as a new attribute named "first_attr1" for each group.
The AttributeCreator_2 replaces 0 "attr1" with the "first_sttr1" value.
Hope this helps.