Skip to main content
Solved

Change the start point of closed curve

  • May 19, 2017
  • 4 replies
  • 30 views

ireen
Contributor
Forum|alt.badge.img+5
  • Contributor
  • 23 replies

Hello,

Is there a possibility to change the start/end point of closed curve?

I created closed curves using the LineCombiner (for merging line segments to 1 closed track with the same start and end point).

Now I have a shapefile with starting points of tracks, and I want the closed curves to start/end in their starting point instead of the random start/end that is created whith the LineCombiner.

Anyone an idea how to do this?

Best answer by takashi

Hi @ireen, this workflow might help you.

Step 1: Remove the last vertex from the closed line, get the number of vertices, decompose the line into individual vertices, and add 0-based vertex index to them.

0684Q00000ArKqhQAF.png

Step 2: Find the index of the vertex that spatially matches the given starting point, and then update every vertex index in the correct order that starts from the given point. 

0684Q00000ArL1rQAF.png

ExpressionEvaluator Parameters

  • Evaluation Mode: Overwrite Existing Attributes
  • Attributes To Overwrite: _vertex_index
  • Arithmetic Expression:
@CurrentAttribute()<@Value(_start_index) ? @Value(_coordcount)+(@CurrentAttribute()-@Value(_start_index)) : @CurrentAttribute()-@Value(_start_index)

Step 3: Re-construct closed line whose vertices have the correct order.

0684Q00000ArKslQAF.png

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

takashi
Celebrity
  • 7843 replies
  • Best Answer
  • May 19, 2017

Hi @ireen, this workflow might help you.

Step 1: Remove the last vertex from the closed line, get the number of vertices, decompose the line into individual vertices, and add 0-based vertex index to them.

0684Q00000ArKqhQAF.png

Step 2: Find the index of the vertex that spatially matches the given starting point, and then update every vertex index in the correct order that starts from the given point. 

0684Q00000ArL1rQAF.png

ExpressionEvaluator Parameters

  • Evaluation Mode: Overwrite Existing Attributes
  • Attributes To Overwrite: _vertex_index
  • Arithmetic Expression:
@CurrentAttribute()<@Value(_start_index) ? @Value(_coordcount)+(@CurrentAttribute()-@Value(_start_index)) : @CurrentAttribute()-@Value(_start_index)

Step 3: Re-construct closed line whose vertices have the correct order.

0684Q00000ArKslQAF.png


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • 23 replies
  • May 20, 2017

I'll give this a try. Thanks for the input!


takashi
Celebrity
  • 7843 replies
  • May 20, 2017

If you would use a PythonCaller to modify the order of line vertices, the workflow could be more concise.

0684Q00000ArKteQAF.png

# PythonCaller Script Example
import fmeobjects
def changeStartVertexOfClosedLine(feature):
    v = feature.getAllCoordinates()[:-1]
    i = int(feature.getAttribute('_index'))
    feature.setGeometry(fmeobjects.FMELine(v[i:] + v[:i+1]))

hansgm
Contributor
Forum|alt.badge.img+6
  • Contributor
  • 9 replies
  • September 26, 2019

Hello

i have a problem with the LineCombiner too.

 

I have lines and arcs and they are sorted in the sequence like i need it.(Sorted with Attributes for line id and element number starting with 0), but the LineCombiner does not start with the first incoming element.

 

How can i force the LineCombiner to start with my first element?

 

Thanks