Solved

Sequence of points


Badge +10

Hey. I need some advice, or at least direction, on how to solve a complex problem. See attachment: I have a track. The track consists of waypoints, the waypoints are minisegments which consist of a startpoint and an endpoint and these minisegments form one big segment and these big segments form one complete track. The direction of the "flow" of the points is determined by the number of startpoints and endpoints, see below, where we see that the only possible direction is from A to E, since it must connect startpoint to endpoint between the minisegments, which form one segment out of three. The waypoints of one of the segments at the level of the points that make up the minisegments look like this - A, F, C, E: 

Startpoint: A
Endpoint: F

Startpoint: F
Endpoint: C

Startpoint: C
Endpoint? E

The problem I'm solving is that some segments have this sequence of startpoint and endpoint reversed in the source data, so that the sequence of points of one of the segments would look like this: E, C, F, A. This is wrong, because from the perspective of the whole track, the points would have the sequence: A, F, C, E   E, C, F, A   A, F, C, E
I need to determine the correct direction of the track based on multiple segment directions - see attachment where two are left and one is right, so the correct direction would be left. However, after determining the left direction, I need to remap the startpoint to endpoint for the remaining segments with the opposite direction so that I have the same direction on all segments to get the result: 
A, F, C, E A, F, C, E A, F, C, E

I came up with this solution:

 

Somehow at the point level, define geographically the direction of the "flow" of points on the individual mini startpoint/endpoint segments, then determine the correct direction based on the direction of most of the segments ( within the mini startpoint and endpoint segments ), then create an imaginary line over the individual segments of the split track to represent the entire track, which would consist of the individual segments. After that, it could work by defining a startpoint and an endpoint on that line ( the first and last point of all segments ) and then below the level of that line the correct points would be stacked, including the segment that would be the opposite - here you would need to remap the startpoint for the endpoint. But how to make this work? I have a coordinate for each point and can create its geometry. I hope I have managed to explain the problem clearly.

Thank you very much.

icon

Best answer by geomancer 10 April 2024, 14:27

View original

17 replies

Userlevel 4
Badge +36

Have you considered the LineCombiner?

 

Badge +10

Have you considered the LineCombiner?

 

How would I need to have data ready for this transformer? Maybe this could be the way to go, but with the complexity of the solution, it will probably be multiple transformers. What part would you solve with linecombiner? Thank you

Userlevel 4
Badge +36

The LineCombiner will consider the points where lines meet for determining which lines to combine.So the start-/end points of the minisegments should coincide, but the direction of the lines is not important. Optionally you can group on a track_ID.

 

Badge +10

The LineCombiner will consider the points where lines meet for determining which lines to combine, so the start-/end points of the minisegments should coincide. Optionally you can group on a track_ID.

 

So I have to create one continuous line without gaps and below the level of this line I can solve the points? But what will it look like data-wise, what will be the input attributes so that linecombiner can handle them correctly? What happens with points that have the opposite direction? Will linecombiner be able to shuffle them? Thank you

Userlevel 4
Badge +36

Input are the short lines from waypoint to waypoint (that you named minisegments). The direction of the lines is not important.

However you have to make sure that the start/endpoint of the different minisegments coincide for lines you want to combine.

Badge +10

Hey. Unfortunately I still can't get the data to process the way I need it to. I used a previously solved situation and decided to upload an fmwt file with one separated problem dataset ( there are about 50 in total ). The example is track L613, where I need points on each segment in this sequence:


Segment 1 ?SML ?KHG ?DEPNO ?BOPOS ?IMREK ?KIVIL ?MMA ?ITEXO ?TANSA ?AMAXI ?VEGES ?DIRMI ?RESTI ?ALANI ?KOR ?RIMAX ?XANIS 
YNN VJOSA - this one is correct

2nd segment PAPIZ GONOT LUMAR MUJAC GARGA RIVAM UTAME - this one is already reversed, in the output of attributeManager_27 you can see in the column list_of_fixes the reverse sequence

3rd segment VIC BORMI DIBAX SUXAN VALAV RONAG ARGAX ELMUR MANEG RIPUS DITON HOC - this one is already reversed

4th segment ?DIPER ?VESAN ?RATUK ?SOVAT ?SANDY ?STOAT ?MOGLI ?BETAX ?MAMUL ?HALIF ?ABKAT ?TLA - this one is correct

The problem is caused by the startpoint being rotated behind the endpoint in the source data and there is nothing I can do about it. Do you think there is any way to solve this?

Thank you very much.

Userlevel 4
Badge +36

Thanks for your example.

In this case it should be possible to calculate the azimuth of each segment before it enters the LineCombiner (some math), and then flip the segments that are in the ‘wrong’ direction using the Orientor.

You can calculate the 'right’ direction from the very first start point and the very last end point.

But this solution may not work for all your data sets.

Badge +10

Thanks for your example.

In this case it should be possible to calculate the azimuth of each segment before it enters the LineCombiner (some math), and then flip the segments that are in the ‘wrong’ direction using the Orientor.

You can calculate the 'right’ direction from the very first start point and the very last end point.

But this solution may not work for all your data sets.

Can I ask you to be more specific about what transformers to use? It is about 1300 flight lines ( there are about 50 such problem lines) and I would need some solution to detect this rotation of the point sequence and reverse the flow of points in the wrong segments.

Thank you

Userlevel 4
Badge +36

I had not noticed that your features are not in any logical order. This makes the process much more difficult.

Is there some way to sort the features? For example by a time stamp that was present before, but is not present in the data you provided?

Of course it is possible to sort by latitude and longitude, but the sorting order would not be the same for different flight lines (ascending or descending).

Userlevel 4
Badge +36

If you can think of a way to sort the features, you can do the following:

  1. Calculate the Azimuth of the complete flight line from the coordinates of the start point of the first feature and the end point of the last feature (it does not really matter if one or both of there are in the wrong direction) 
  2. Add this azimuth to all features, and identify the features whose azimuth is in the 'wrong’ direction
  3. Flip the features that head in the wrong direction
  4. Now continue with the LineCombiner

This works for the data you provided without sorting, but it would be better if you could find some way to sort the features.

I used the HorizontalAngleCalculator from FME Hub to calculate the azimuths, of course you can also add your own formula.

 

Badge +10

If you can think of a way to sort the features, you can do the following:

  1. Calculate the Azimuth of the complete flight line from the coordinates of the start point of the first feature and the end point of the last feature (it does not really matter if one or both of there are in the wrong direction) 
  2. Add this azimuth to all features, and identify the features whose azimuth is in the 'wrong’ direction
  3. Flip the features that head in the wrong direction
  4. Now continue with the LineCombiner

This works for the data you provided without sorting, but it would be better if you could find some way to sort the features.

I used the HorizontalAngleCalculator from FME Hub to calculate the azimuths, of course you can also add your own formula.

 

This looks like it might work, I'll try to work out a solution and let you know. I really appreciate your knowledge. Thank you very much for the attached ws.

Userlevel 4
Badge +36

Good luck, thanks for the feedback!

Badge +10

Good luck, thanks for the feedback!

Hey. I have tried applying to all problem lines with small adjustments and the solution does not always work - for L613 it works great, thanks again :-) If I'm not mistaken, or please correct me, the problem might be the value on the testfilter transformer, where the value is set to 135 and is not logically functional for the other tracks, because they have different azimuths of the whole flight line? You derived this 135 value based on the azimuth calculation, am I understanding correctly? If this is the case, I will probably have to replace the testfilter with some script that would dynamically add this value ( the original 135 ) based on the azimuth calculation of the entire flight line, do I understand correctly?

Thank you very much

 

Userlevel 4
Badge +36

The value 135 does not depend on the azimuth of the entire flight path.

In the TestFilter I calculate the (absolute) difference between the azimuth of an individual segment and the calculated approximate azimuth of the whole flight path. My thought was that every value > 135 would indicate a segment that points the 'wrong’ way.

Badge +10

The value 135 does not depend on the azimuth of the entire flight path.

In the TestFilter I calculate the (absolute) difference between the azimuth of an individual segment and the calculated approximate azimuth of the whole flight path. My thought was that every value > 135 would indicate a segment that points the 'wrong’ way.

Do you think 135 will work on all lines in different directions? So I need to play with it some more and see why it gives me non-valid data with the whole dataset.

 

Anyway, thank you very much, I'll let you know.

Badge +10

Hey. Do you have any idea how to solve the sequential processing of input elements on HorizonAngleCalculator? The idea is to process the next row of data after the first row of data is completed. I would put a featureholder after the HorizontalAngleCalculator and it might work. I've tried testing the featureholder with counter and filtering features that have already been processed, but somehow I can't get it to work. 

Thank you very much

Userlevel 4
Badge +36

Continues here.

Reply