Friday, April 4, 2008

Google Maps, Maemo Mapper, GPX, KML all get me to the rally!

I'm a bit of a rally fan. Not the political kind, but the motorsports kind (you may have see it in the x-games...). This weekend is the 2008 Rally New York. If you've ever been to a rally before you know what a pain it is finding and getting to spectator points. If you haven't, I suggest you do, and believe me, it's a pain. There's usually a spectator guide and if you dig around the site some scanned maps that have been marked but these always leave me a little in the dark. So each time I go to one of these I usually take a few hours checking out google maps and figuring out where the spectator points are and how to get there.


It started out with just printing out the pdf's and the maps, but then I got a psp and I started downloading Google maps and drawing on them and loading them as pictures. Then I got the Nokia N800, suddenly there was no need for print outs (yay! I'm going green while driving > 300 miles to a fuel burning frenzy). The N800 can handle PDFs and with the help of Maemo Mapper can handle maps for me. That coupled with a bluetooth GPS receiver gives me a really great tool for navigating to the different points. Now I have an iPhone as well which has maps and PDF abilities (if it only had GPS!)
So what I did this year was plot everything on Google Maps:


View Larger Map

The cameras are spectator points. The orange lines are the closed road courses and the blue lines are the recommended approaches to the spectator areas. While editing a map you can download the kml file to view in Google Earth. This file just contains a link to the actual .kml file that has the lines and points in it. I tried putting this file on a server and hitting it in my iPhone's maps.app. But after getting a polite error about not being able to find anything matching the search I looked on the web and found that the only kml elements Google Maps for Mobile (which maps.app is based on I hear) is the point. So lines were out and my iPhone was out.


Next I looked up what format Maemo Mapper supported, which is GPX. I fired up gpsbabel and converted my real kml file to gpx only to have Maemo Mapper choke on it. It turns out that Mapper wants only one type of dataset at a time. The kml had lines and points which were converted to "trk"'s and waypoints. But I really only needed to store my spectator areas as Points of Interest (POI). Mapper stores it's POI in a sqlite3 database in /home/user/MyDocs/.documents/Maps/poi.db by default. By getting that file I was able to write a ruby script that took out the "Point" elements from the kml file and create sql insert statements. Putting that db back and fixing permissions (I was ssh'd in as root so the file became pwn'd) gave me the spectator points. Since they're the only things in there it makes for very easy viewing!


Then came the "approaches", I have them as line fragments on the google maps but Mapper only supports Routes and tracks. I don't know if tracks would have helped me as I think they're in a db called paths.db but the routes are stored in an xml file in gpx format. Gpsbable dropped the names and descriptions when it converted the lines so I created a new ruby script that took the LineStrings from kml and created trkpt's from them. Reloading the route file in Mapper gave me my route to the place plus the route fragments to the spectator areas. Since they were all in the same route file I could then download tiles around the routes and have everything internet free. I also added a description to some of the points in the line for turn directions/hints. You can count the bends in your google map to know which one to add it to and remember it goes at the beginning of a line not the end. So if you have a right turn between segment 2 and 3 add the turn description to segment 3.


Hopefully that'll be everything I need. I'm bringing my old phone just in case I need to tether (damn you iPhone and your lame bluetooth support) to the N800 for data. Now about that battery life...

No comments: