means i have to build now a topology and join the lines which belongs to one leg.
.....
Hi Franco,
Â
Â
I suppose that the rule is:
Â
If the attribute "A" of a line is equal to the attribute "C" of the previous line, then the two lines have to be connected.Â
Otherwise, the two lines should not be connected even if they are touching each other at the end nodes.Â
Â
If my understanding is correct, this could be a way.
Â
(1) LineJoiner
Â
- List Name: _list
Â
- Preserve Lines as Path Segments: Yes
Â
Â
(2) PathSplitter
Â
- List Attribute: _list{}
Â
Â
The LineJoiner and the PathSplitter will sort the lines in their connecting order. If the input lines have been sorted in the order from the beginning, the two transformers are not essential.
Â
Â
(3) AttributeExposer
Â
- Attributes to Expose: _group
Â
Â
(4) AttributeCreator with the "Prior/Subsequent Feature Attribute Retrieval" option (called "Multiple Feature Attribute Support" in FME 2014).
Â
- Number of Prior Features: 1
Â
- If Attribute is Missing, Null, or Empty: Use Empty String
Â
- Attribute Name: _group
Â
- Value (Conditional Value Setting):
Â
If featurei-1]._group =
<empty> Then 0
Â
Else If A = featureÂ-1].C Then featuree-1]._group
Â
Else featureg-1]._group+1
Â
Â
(5) LineJoiner_2
Â
- Group By: _group
Â
Â
Takashi
Hi,
Â
thank you Takashi...it function but i told you maybe not the full truth ;-))
first of all "use empty string" ??...i have only 3 options there : - Use Attribute Value, Use Fallback Value or Use Attribute Value of Closest Feature....??
Â
but it function except here: (see screenshot)
Â
Â
Â
the yellow line should be also connected with blue in the north, but i think that cannot function because the Line joiner has two options here (means two lines) the line in the north, which has the right attribute value, and the line turns left which has NOT the right attribute value....expect on this cases the line joiner DO FUNCTION.
Â
Â
Greetz
Â
Franco
oh, sorry. I looked at the AttributeCreator in FME 2014.
Â
In FME 2015, choose the "Use Fallback Value" option and leave blank the "Fallback Value" parameter field.
Â
Â
What kind of the rule for combining the yellow line and the northern blue line is?
its the same rule but he stops connecting where he have a right option and a wrong option....right option is blue in the north, wrong option is blue left...he do it right where 3 lines comes together and he has two wrong options....
hmm, not clear...
Â
Â
Perhaps your goal is to build a topologically clean network?
Â
i.e. the blue lines should be divided at the point intersecting with the yellow line?
now the result is the line joiner stops connecting at the place but he shouldnt because the yellow line should be connected to the blue line in the north because the attribute values are right..but i think i've done a fault...I'm not so familiar with these expressions....added screenshots
Â
Â
Â
Â
Â
Â
Â
Greetz
Â
Franco
isn't it right to give him another option?
now he has option 1 attribute value is right do connect........option 2 attribute value is wrong do not connect....but when he comes to a point where he have option 1 and option 2 should we give him not the possibility to decide for option 1...or is this already implented by this expression?
The Conditional Value Setting I intended should be:
Â
Â
Â
hmm....i set it up that way...now the result is that he connects nothing......
line joiner is group by _group....think thats stays right or?
hmm....
i have for the test 9019 features and the _group attribute result after Attribute creator is from 0 til 9018
sad to hear that...
Â
Â
Well, rethink from the beginning.
Â
The AttributeCreator approach requires that the input lines have been sorted in the connecting order. i.e. WSNO of the 1st line is equal to USLINKNO1 of the 2nd line, the 2nd WSNO is equal to USLINKNO1 of the 3rd, and so on.
Â
If the lines have not been sorted, you will have to sort them beforehand.
Â
Â
In my first post, I suggested the LineJoiner+PathSplitter to do the sorting, but it would not work as expected since there are a node to which 3 lines connect together. I didn't assume such a situation.
Â
Â
Is there any condition which  can be used to sort the lines in the connecting order?
Â
e.g. WSNO or USLINKNO1 value can be used to sort the lines?
hmmm....
i didnt take the option to sort them because they are sorted.......
i think i have confused you...
alle lines are sorted with this rule.....
but i have nodes where three lines comes together....and there i have 2 situations
1. situation...line 1 is connected to that point...line 2 should not be connected (has wrong attributes either) and line 3 should also not be connected (has wrong attributes either).....this is situation he checked after your first solution......
2. situation...line 1 is connected to that point....line 2 schould be connected (because of right attribute value) and line 3 should not be connected (because of worng attribute value).....this situation doesn't work because he ends to connect here.
sry...for my confusing declarations
Greetz
Â
Franco
no attribute value alone can be used for sorting.....only the logical connection between USLINKNO1 and WSNO...
The AttributeCreator gives an identical "_group" number to each line while "WSNO" of the prior line is equal to "USLINKNO1" of the current line.
Â
For example, if these lines have come, all of them will have same group number.
Â
Line1: WSNO = 1, USLINKNO1 = 0
Â
Line2: WSNO = 2, USLINKNO1 = 1
Â
Line3: WSNO = 3, USLINKNO1 = 2
Â
Line4: WSNO = 4, USLINKNO1 = 3
Â
...
Â
And when "WSNO" of the prior line is not equal to "USLINKNO1" of the current line, "_group" number will change (increment) for the next group.
Â
It was my intention to use the "Prior/Subsequent Feature Attribute Retrieval" option and the "Conditional Value Setting" in the AttributeCreator.
Â
Â
Is the AttributeCreator working as expected?
Hi Takashi,
Â
I'm confused...maybe i did something wrong...but i think you will check it immediately with these screenshots
Â
shot1: my settings in the Attribute Creator
Â
Â
Â
Â
shot2: three results after Attribute Creator where you can see the attributes .....all three lines should be connected in the final........
Â
Â
Â
Â
Â
Â
so where is the fault?......now result is the line joiner in the end cannot connect it right because of wrong _group attributes......some lines have the right _group attributes but only a few......
The 1st line: WSNO=
32535, USLINKNO1=32495, _group=
8545Â
The 3rd line: WSNO=33303, USLINKNO1=
32535, _group=
8457Â
Â
Since "WSNO" of the 1st line is equal to "USLINKNO1" of the 3rd line, the two line should have same "_group" if they are input to the AttributeCreator in the order of 1st -> Â 3rd continuously.
Â
However, according to the values of "_group" (3rd:8457 < 1st:8545), the 3rd line has come earlier than the 1st line, and also they are not continuous in the input sequence.
Â
Unfortunately, the precondition "input lines have been sorted in the connecting order" is not satisfied, at least in these two lines.
Â
That's why the AttributeCreator doesn't work as expected.
Â
Â
Regarding the 1st line and the 2nd line, there is another short line between them, so I cannot check the reason that they were not connected.
Hi Takashi,
Â
so i have to sort the lines before with LIne Joiner and the PathSplitter right?
here is also a screenshot from the little line between 1.shot and 2.shot
Thank you very much for taking time on this!!
Â
Â
1st, 2nd and the little line are also not continuous.
Â
It's necessary to sort when adopting the AttributeCreator. But, since there are node to which 3 lines intersect together, the LineJoiner+PathSplitter method will not work perfectly.
Â
I need to rethink...
At a node in which just two lines touch, the two lines can be connected always?
Â
Or, could there also be a break point at such a node?Â
at a node where only two lines touch the two lines can be connected always.!!
Â
Â
only on a point where three lines touch...can be 2 possibilities:
either all three lines are separated legs and belongs to three separate groups or
like the case you know from the screenshots....two lines had to be connected and one belongs to another stream.
Franco, unfortunately I was not able to find a way to resolve it by using existing transformers only. I finally fell into the temptation to use Python...
Â
Â
The PythonCaller with this script adds "_group" attribute to input features.
Â
Set "_group" to the "Attributes To Expose" parameter of the PythonCaller.
Â
Assume that both "WSNO" and "USLINKNO1" contain integer value and also there are no duplicate values in "WSNO" and "USLINKNO1".
Â
You can remove the AttributeExposer and the AttributeCreator if you adopt this.
Â
-----
Â
# Python Script Example
Â
import fme, fmeobjects
Â
import collections
Â
Â
class FeatureProcessor(object):
Â
  def __init__(self):
Â
    # Set of all input features.
Â
    self.features = set( ])
Â
    Â
Â
  def input(self, feature):
Â
    # Store the input feature in the Set.
Â
    self.features.add(feature)
Â
    Â
Â
  def close(self):
Â
    # Connection key attribute names.
Â
    frontAttr = 'USLINKNO1' # forward connection key
Â
    backAttr = 'WSNO' # backword connection key
Â
    Â
Â
    # Create two dictionaries.
Â
    # d1: key=forward connection key, value=feature
Â
    # d2: key=backword connection key, value=feature
Â
    d1, d2 = {}, {}
Â
    for feature in self.features:
Â
      front = int(feature.getAttribute(frontAttr))
Â
      back = int(feature.getAttribute(backAttr))
Â
      d1Afront] = feature
Â
      d2Âback] = feature
Â
Â
    # Initialize group ID.
Â
    id = 0
Â
    Â
Â
    while 0 < len(self.features):
Â
      # Retrieve and remove a feature from the Set.
Â
      feature = self.features.pop()
Â
      Â
Â
      # Create and initialize a group.
Â
      group = collections.deque()
Â
      group.append(feature)
Â
      Â
Â
      # Initialize forward/backward connection key.
Â
      front = int(feature.getAttribute(frontAttr))
Â
      back = int(feature.getAttribute(backAttr))
Â
      Â
Â
      # Append backward connectable features to the group.
Â
      while d1.has_key(back):
Â
        # - retrieve and remove a feature from d1 dictionary.
Â
        # - append the feature to the group.
Â
        # - remove the feature from the Set.
Â
        # - update backword connection key.
Â
        feature = d1.pop(back)
Â
        group.append(feature)
Â
        self.features.remove(feature)
Â
        back = int(feature.getAttribute(backAttr))
Â
        Â
Â
      # Append forward connectable features to the group.
Â
      while d2.has_key(front):
Â
        # - retrieve and remove a feature from d2 dictionary.
Â
        # - append the feature to the group.
Â
        # - remove the feature from the Set.
Â
        # - update forword connection key.
Â
        feature = d2.pop(front)
Â
        group.appendleft(feature)
Â
        self.features.remove(feature)
Â
        front = int(feature.getAttribute(frontAttr))
Â
      Â
Â
      # Set group ID and output features in the group.
Â
      for feature in group:
Â
        feature.setAttribute('_group', id)
Â
        self.pyoutput(feature)
Â
        Â
Â
      # Update group ID for the next group.
Â
      id += 1
Â
-----
P.S. If you use the script, you can set "Yes" to the "Input is Ordered by Group" parameter of the following LineJoiner transformer.
A different approach flashed in my mind.
Â
The basic strategy is: at the node where 3 lines are intersecting, shorten the line that should not be connected there so that it will not be treated by the LineJoiner; restore the shortened part by another LineJoiner later.
Â
Right figure illustrates the situation after the shortening. The left-top line is the one that should not be connected at the node.
Â
Â
Â
The data flow is a little complicated, so it's hard to explain correctly by my poor English.
Â
See this demo workspace. (
https://drive.google.com/file/d/0B0ufVP2t0eApX0ZnUllUblktczQ/view?usp=sharing)
The previous demo workspace didn't support the case where all the 3 lines should not be connected each other.
Â
This is the upgrade version to support that case. (
https://drive.google.com/file/d/0B0ufVP2t0eApM3VydkpDektPTGM/view?usp=sharing)