0

Basically I want to take an array of coordinates in long,lat format (qgis exports them that way by default it seems) and compress the coords as lines (two pairs at a time) for storage in a custom app for a navigation device I guess like this:

Line 1 = Point A, Point B -> compress together

Line 2 = Point B, Point C -> compress together

Etc

Then in the xml save the compressed pairs of each line by the location of the first pair of the two pairs (still following?). Basically if Line 1’s point A is within such n such distance to Line 2’s point B then save them in the same array of json data in an xml, else if Point B is not within such n such distance of Point A then save Point B in a new line of Json data. Ideally with the such n such distance being configurable I guess, perhaps also the amount of compression too (e.g for use with a smaller dataset less compression to retain more accuracy)

Then obviously to draw the gpx on the navigation device I would use the same decompression algorithm (but translated into Monkey C which I do know) but due to the fact the large gpx would now be chunked by location it would save the gps devices memory.

Example coords data (extracted from a gpx via qgis) 141.289,-2.703,141.182,-2.666,141.067,-2.654,141.017,-2.629,140.836,-2.625,140.733,-2.658,140.683,-2.641,140.663,-2.6,141.289,-2.703,141.562,-2.814,141.586,-2.835,141.793,-2.926,141.854,-2.984,141.991,-2.984,142.032,-3.008,142.04,-3.041,142.069,-3.078,142.131,-3.083,142.189,-3.111,142.329,-3.144,142.387,-3.19,142.543,-3.272,142.815,-3.338,142.873,-3.363,143.108,-3.392,143.141,-3.408,143.228,-3.408,143.447,-3.458,141.289,-2.703,141.182,-2.666,141.067,-2.654,141.017,-2.629,140.836,-2.625,140.733,-2.658,140.683,-2.641,140.663,-2.6,141.289,-2.703,141.562,-2.814,141.586,-2.835,141.793,-2.926,141.854,-2.984,141.991,-2.984,142.032,-3.008,142.04,-3.041,142.069,-3.078,142.131,-3.083,142.189,-3.111,142.329,-3.144,142.387,-3.19,142.543,-3.272,142.815,-3.338,142.873,-3.363,143.108,-3.392,143.141,-3.408,143.228,-3.408,143.447,-3.458

Desired outcome example (Note the array of coords I have presented would oresult in a larger amount of data then the example data I’ve provided below.):

<JsonData<id=“0m_2” [234579462255,63528290278,63729294736]>/JsonData>

<JsonData<id=“0m_3” [8495794622,63528290246,25382947482]>/JsonData>

Each number is two pairs of coords sorted

SuperStormer
  • 4,997
  • 5
  • 25
  • 35
  • Please supply sample gpx data together with the desired outcome; two or three examples to make it clear what you are trying to achieve. And while you are editing your question, please remove the remark that you are a coding noob and don't know where to start; it clutters the question and what's worse, it suggests the whole question is off-topic. – Ruud Helderman Aug 09 '22 at 12:40
  • @RuudHelderman Done, I hope I have edited it to your satisfaction. – IceBear123 Aug 10 '22 at 06:06
  • Unfortunately not. The coordinate dump is not useful, for two reasons. (1) I don't know how to interpret it. Doesn't look like GPX at all. What is `141.289,-2.703`? Longitude followed by latitude? I'm fine with an unconventional order of coordinates, but then _say so_. (2) No clues about what you are trying to achieve. An example should provide input _and_ output, in a way that demonstrates how the output relates to the input. You said you wanted to generate JSON with points grouped into lines based on their mutual distance. Please exemplify this! – Ruud Helderman Aug 10 '22 at 16:36
  • @RuudHelderman Ah! Sorry I misunderstand, I am very literal so interpret things differently, I shall edit things further and clarify some stuff too. – IceBear123 Aug 11 '22 at 17:24
  • @RuudHelderman ok I think i’ve got what you asked for, hope it helps. – IceBear123 Aug 11 '22 at 19:09
  • I don't see how this demonstrates how the output relates to the input. I only see arbitrary numbers; no logic. Without logic, there is nothing that can be programmed. The question needs a technical design or some preliminary code; otherwise it is off-topic for SO. – Ruud Helderman Aug 13 '22 at 13:48
  • Those are numbers I typed at random, the converter I use compresses the coords to numbers but does not fully suit my purposes and is made by someone else shall I share it to you via onedrive? You can see the html but I have no idea as to how it works. – IceBear123 Aug 14 '22 at 14:17
  • So you want to reverse-engineer some existing converter until you understand what it does and how it works, then adjust or rewrite it until it meets some new requirements, but you have no idea where to begin. That is not a question, that is an assignment. I hope you understand SO is neither a free coding service, nor a programming tutorial. – Ruud Helderman Aug 15 '22 at 20:25
  • I understand, though I shouldIt would be unreasonable of me to expect you to type out something for me I understand, that does seem lazy, I may attempt to try the creator themselves. That or do you know where I might find the best place somewhere where I can find out how to read html to understand the thing by myself. – IceBear123 Aug 17 '22 at 06:19
  • @Rudd Helderman Scratch that, i’ve just remembered I forgot to include another aspect of the post, I didn’t intend for anyone to have to make me anything, I’ve already started an equivalent in scratch using my own code, however became stuck so came here wanting to know if theres another language I could use thats as simple (what to use) or to learn of some simple algorithm i could recreate in scratch (where to start). However upon creation of this post I completely forgot to include that until now…Perhaps I should have lead with this… – IceBear123 Aug 17 '22 at 06:33

0 Answers0