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.