Hein (fub) wrote,
Hein
fub

  • Mood:

Old-school hacking

I'm processing the GPS tracklogs of our days in Japan, so that I can generate cool-looking Google Maps of where we've been, just like I (sometimes) do when we go geocaching. Obviously, we'll be geocoding klik's photos too, and making markers of those for that interactive experience.

I used to edit the GPX-files by hand, but that meant that I had to run the GPX-file through the GPS Visualizer multiple times to see what would become of it. I was very pleased when I found Viking, an open-source GPX-editor that draws the tracklogs and waypoints on top of a map layer. That way, you get a preview of what it would look like superimposed on a Google Map -- and editing tracks is very easy.

One of the things Viking can do is merge track logs if the end of one and the start of the second are within a specified time frame of one another. When you walk into a shop and the GPS receiver loses its fix, it will start a new track log when it reacquires a fix -- and if you want those two tracks to be combined, that feature works quite well.
However, Viking will greedily add the next track if that is within the time frame too, and the next, and so on. Sometimes, you don't want that -- sure, you can split tracks again with Viking, but why should I first add everything together and then re-create the previous situation? So I wanted to be able to add two specific tracks together.

So I downloaded the source from the subversion repository and had a look. It's all written in C, with the interface and many, many data-structures done through the GTK library (the foundation under such things like Gnome, the default Ubuntu desktop environment). I used GTK widgets in my own programs, but those are the Python bindings -- in C, there are such things like allocations, pointers and freeing memory to think of. Less... elegant, somehow.
Anyway, grepping through the source showed me where the context-menu for layers was. With a bit of fiddling, I added my own option (people who know my style of code won't be surprised to find that this option was titled 'PIPCO') and my own callback function. From that, I expanded into creating a new dialog, populating a list with the names of all the tracks (but not the one that was currently selected) and merging the current track with the selected track. All by using the existing code as an example, along with the GTK online reference manuals. By the end of the evening, it was working as I had intended.

Which pleases me more than it probably should. At work, I try to do as little programming as possible, because I'm trying to be more of a manager than a programmer. But at home, I get to fix things. :)

I submitted my patch this morning. Haven't heard back from the developers yet, but I expect that it will be included without too much problems. Open source FTW.
Subscribe

  • RPGaDay 3: Tactic

    Day 3 of RPGaDay, and today’s topic is ‘tactic’. In RPG terms, a game is called ‘tactical’ if it involves…

  • RPGaDay #2: Map

    I love maps, of both real and imagined places. I love to see how things relate in space, and how seeing the layout of something allows you to make…

  • RPGaDay #1: Scenario

    The start of August marks the start of RPG-a-Day, and like with previous years, I’ll be participating! Day #1: Scenario I love reading…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments