Question

Automatically getting the direction of a forked line

  • 28 November 2018
  • 6 replies
  • 3 views

Badge

I have a network of railway switches and I need to assign the value of a switch line being left or right automatically.

What do I have: A feature class containing a track that looks like this

I need to generate something that looks like the following.

The red arrow is always the direction you look at the intersection and that helps you determine if the lines branching out are left or right.


6 replies

Badge +3

@sraapril

 

You could

Chopp the lines by 2vertices. Create an unique ID on these. Extract orientation.

Extract begin and end coordinates.

Create a attribute RoundeCoord=@round(coord,6)

Create a list grouped by this latter attribute.

Test for listelementcount = 3. That your fork.

Compare angles within the group. Angles with a separation in (min,max) separation dictate fork direction.

Between the 2 within the separation angle, the lower angle is the right side if in 2nd and 3rd quadrant. The other two quadrant is revers.

 

 

do you have sampledata for us? (one in image is very suitable)

Badge

@sraapril

 

You could

Chopp the lines by 2vertices. Create an unique ID on these. Extract orientation.

Extract begin and end coordinates.

Create a attribute RoundeCoord=@round(coord,6)

Create a list grouped by this latter attribute.

Test for listelementcount = 3. That your fork.

Compare angles within the group. Angles with a separation in (min,max) separation dictate fork direction.

Between the 2 within the separation angle, the lower angle is the right side if in 2nd and 3rd quadrant. The other two quadrant is revers.

 

 

do you have sampledata for us? (one in image is very suitable)

Hi @gio.

Thank you! The orientation extractor always returns no orientation.

When you mean list, do you mean the 3 coordinate list of the fork? After I get the three coordinates, how do I calculate the angles?

Polyline analyzer, Vertex Angle Calculator, I mean nothing gives me any value 😞

The image I posted above is the best sample dataset. I have attached a shapefile of the same.

TRACK_DATA.zip

Badge +22

I would use a topologyBuilder.

 

Test the nodes for those containing three elements.

 

Subtract the _node_angle{}.fme_arc_angles from one another, if the difference is more than 180 use the explementary angle (360-angle)

 

The smallest difference in angles correspond to your forks. The third line is your lead-in.

Since the _node_angle list is always ordered counterclockwise, the next index after your lead in (wrapping to 0 if the lead in is 2) is the right segment.

 

 

Badge +3

@sraapril

Hi,

I made a workbench doing it.

I did it slightly different form what I posted before.

Difference is I use Topologybuilder and snipper (rather then chopper).

I'll post it here and hope you can download it.

sraapril_forum.fmw

track-branch-lr

Badge +3

@sraapril

Here is annotated pic of the workbench.

It is built for "binary" branching.

If you have switches with more then 2 branches, the section between the testfilter and the listexploder need to be adapted. (at which point you have to create something like "from_left_to_right numbering")

 

Badge +22

Here is an alternative workspace based on my workflow. The size of the switches is hardcoded, but could easily be parameterized. It is also adaptable to have the left and right assigned to the original line features, but that would require 2 feature mergers, one for the start of the line (from_node) and one for the end of the line (to_node).

 

sideFork.fmwt

Reply