Hack 63. Build Your Own Car Navigation System with GpsDrive

Watch your position on a map move as you move. What a novel concept!

Thomas Hargrove is right in [Hack #62] that having an in-car (or on-bike) navigation system makes you the envy of all your (geek) friends. GpsDrive is an open source Linux, FreeBSD, and Mac OS X program that connects to a GPS and displays your current position and your track on a map. GpsDrive also has an interface to aid you in downloading maps from Expedia, or you can make your own maps.

One night I tested the program's map-download function on a drive down to a hosting center in Fremont. I needed to add another hard drive to the server that hosts http://geocoder.us and http://mappinghacks.com. As I headed south, I left the area of the GpsDrive map that I had prepared in advance. If you drive off of the current map, GpsDrive stops showing your current position. So when I pulled up at a stoplight in San Francisco, I connected to a random open wireless network and downloaded a map. I repeated this pattern through most of the city: stop at a light, try to connect, download one or two maps, and then pull away.

There is something strangely compelling about seeing your track as it picks its way across a map that you just downloaded while stopped at a light.

5.19.1. Installing and Using GpsDrive

GpsDrive is available at: http://www.gpsdrive.de. Under Linux, download the appropriate RPM and then type:

$ rpm -ivh gpsdrive-2.09.i386.rpm.

Of course, you can also compile from source code. Under FreeBSD, use the ports collection:

$ cd /usr/ports/astro/gpsdrive
$ sudo make install; make clean
$ rehash

And then start GpsDrive:

$ gpsdrive

GpsDrive supports various GPS options. I connected a Garmin III plus to the serial port on a machine running Fedora Core 2. In GpsDrive, click on Preferences images/ent/U2192.GIF border=0> Settings 2. I set my GPS to communicate in NMEA mode, and so I selected "Use serial conn" to directly talk to the serial port. I set the serial port to /dev/ttyS1, and then used chmod to set the permissions on /dev/ttyS1. NMEA talks at 4800 by default, so leave that alone.

Clicking "Download map" brings up the dialog shown in Figure 5-44. You can select the source of your map and the scale. The filename is automatically incremented, so you can download as many maps as you want. The maps are stored as GIF images in the directory specified under Preferences images/ent/U2192.GIF border=0> Settings 2 images/ent/U2192.GIF border=0> Maps directory. GpsDrive uses the file map_koord.txt (can you tell it was written by Germans?) as a simple georeferencing system.

Figure 5-44. GpsDrive map download window

A sample map_koord.txt file:

map_file0000.gif 38.44337 -122.71536 3950
map_file0001.gif 38.44346 -122.71544 98750

In this example, map_file0001.gif is centered at 38.44346, -122.71544 and will be shown when you zoom out at a scale of about 1:100,000 (Figure 5-45).

Figure 5-45. Downloaded map in GpsDrive

When you zoom in too far, you can see the effects of wandering GPS accuracy. In Figure 5-46, you can see a "track" I gathered while standing still.

Figure 5-46. Zooming in while sitting still shows the effects of GPS "drift"

 

5.19.2. Adding Your Own Maps

Since GpsDrive maps are regular images, you can create your own maps. A GpsDrive map is a 1280 1024 pixel GIF image. You can use the Misc Menu images/ent/U2192.GIF border=0> Maps images/ent/U2192.GIF border=0> Import map tool to import a map, or you can directly edit the map_koord.txt file.

Any image named map_filennnn (where nnnn is replaced with a number) can be used as a GpsDrive map. You can also edit the maps that GpsDrive downloads from Expedia. Maps are stored in your home directory in ./gpsdrive.

Each line contains a filename, the latitude at the center of the map, and a scale. So you can customize a map by taking an existing map and adding your own annotations. If you select "Auto Best Map" from the checkboxes on the left side of the screen, GpsDrive will automatically pick the best scale for the map. You can then set the largest-scale maps to be regular photographs. It's fun to pull up at your destination and have your navigation system show you a picture.

5.19.3. Playing Nice with Others

Since GpsDrive can use gpsd [Hack #57] , you can run other GPS-aware applications in conjunction with your navigation system. For example, you can run Kismet to do network wardriving [Hack #17], and the gpslogger.pl script [Hack #58] to allow you to do real time geo-annotaion.

If you like the program as much as I do, then send Friedrich Ganter a few dollars to help with his hosting fees. The PayPal donation link is on the GpsDrive site.

Now have fun with GpsDrive, but (and you can hear this one coming, right?) please be careful while driving (and yes, I mean you, with the laptop balanced on the console, cup of coffee in one hand, cell phone in the other, fumbling with your GPS, trying to get a signal lock!).

Mapping Your Life

Mapping Your Neighborhood

Mapping Your World

Mapping (on) the Web

Mapping with Gadgets

Mapping on Your Desktop

Names and Places

Building the Geospatial Web

Mapping with Other People



Mapping Hacks
Mapping Hacks: Tips & Tools for Electronic Cartography
ISBN: 0596007035
EAN: 2147483647
Year: 2004
Pages: 172

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net