0

There is a task, it is necessary to determine rectilinear movement among the transmitted GPS coordinates (without any binding to roads, water bodies, etc.). I converted the received GPS coordinates into H3 hexes (the level does not matter, you can use any, the main thing is to try to improve the accuracy). As a result, there is such an idea - to take the starting point (initial hex) and watch the next hex (according to the transmitted timestamp), and then further along the chain. At the output, the maximum STRAIGHT length of the hexes by displacement must be found. Accordingly, it is necessary to somehow understand that the next hex lies from a certain angle of the previous hex. The following questions arose:

  1. each hex has a unique hash, is it possible to access the neighboring hex somehow? Each hex has 6 edges, if we draw an analogy with a clock, then the uppermost part of the hex = 1, and then clockwise up to 6. We take a hex, remember its hash, look at the next one, if the next hex lies from any corner and BORDERS on the previous one, then we put it in some way, then we look at the next hex, if it lies from the same angle as the previous one, then we remember this and move on. If further the next hex does not border on the previous one, or borders on the other side, then we will assume that the direction of movement has changed. As a result, we print the start point, end point and duration (number of unique hexes) that represent a straight line from you (in any direction).
  2. you can try to look through the level of neighbors (but I don’t know how). For example, the initial point is the cent, then we look for neighbors that lie through one level and determine the direction, then we look through another level and so on. For example, I drew a diagram. Green points are marked by hexes, and the direction of movement. According to the current logic, you need to display the number 5 (as the duration of continuous and straight hex bundles), as well as the hash of the hex (marked as the beginning of the maximum continuous movement) and the hash of the end. Highlighted in blue the second track, which should output 2 and the hashes of the two corresponding gecos.

You need to write all this in pyspark / sql / or in python

enter image description here

0 Answers0