Question

Sort lines based on connectivity

  • 15 January 2015
  • 5 replies
  • 27 views

Badge +5
Hi All,

 

I have a series of lines that I know are connected by end points and the lines eventually form a polygon. They can be connected from the end of one line to the start of another (the default expected connection) but can also be end to end or start to start. 

 

Assuming all are end-to-start and that I have a sort_order integer field on the line(s), is there a way to populate the sort_order field so that the sort_order is sequential based on the connectivity? I've looked at http://fmepedia.safe.com/AnswersQuestionDetail?id=906a0000000cjmoAAA and it gets me close as it allows me to find the related end points but I just need to now find the order. Also, using LineOnLineOverlayer point output also did close to the same thing. I just need a little shove to get over the hill...

 

I'm using FME.2014 SP5

 

Thanks in advance,

 

Brian

5 replies

Userlevel 2
Badge +17
Hi Brian,

 

 

Once connect all the lines that are touching each other at the end nodes with the LineJoiner (Preserve Original Orientation: no, Preserve Lines as Path Segments: Yes), and then split resulting paths with the PathSplitter.

 

The PathSplitter will add the Segment Number Attribute (called "_segment_number" by default) which will contain your required sort order.

 

And, if you want to preserve attributes of the original line,

 

- specify a list attribute name to the "List Name" parameter of the LineJoiner,

 

- set the "List Attribute" parameter of the PathSplitter to the list name.

 

 

In the procedure, FME will adjust automatically orientation of lines belonging to a same path into the same direction.

 

If you need to restore the original orientation, see the hidden attribute named "direction" that will be given by the PathSplitter. It contains "same" or "opposite", you can check if the direction of the resulting line is same as the original line, and restore the orientation of the "opposite" lines with the Orientor (Orientation Type: REVERSE).

 

 

Takashi
Userlevel 2
Badge +17
correction.

 

The "direction" attribute will be given by the LineJoiner when you specified the "List Name".

 

 
Badge +3
This is one (of many i assume) to do it.

 

 

 

 

Overlay is in this because i had more than 1 object in my file. If you work on 1 object only you can skip overlay and tester_2.

 

 

The original points were not ordered, after this they are.
Badge +5
Thank you both for your excellent responses. I hope to test them later today.

 

An additional requirement pertains to the starting point. I know the start point vertex to start counting from (the Point of Commencement is an x,y coordinate in a separate feature class) so I need to inject that workflow now as well.

 

Thanks again for sharing your knowledge. It's invaluable for us newbies.

 

cheers...B
Userlevel 2
Badge +17
Divide the original lines into the first one and others.

 

To the first line, give the first sort order attribute (e.g. 0).

 

Give 0-based segment number to other lines with the procedure I mentioned first, and then, add 1 to their segment number with the ExpressionEvaluator.

Reply