
284
|
Chapter 5, Mapping with Gadgets
#62 Build a Car Computer
HACK
This code requires a Python module called pySerial. This module is avail-
able at http://pyserial.sourceforge.net/.
Displaying GPS Data in a GUI Application
Text-based mapping software is not very exciting. A more useful approach is
to render map data onto a 2-D window. In the following example, we will
see how to build a cross-platform Python application that uses the Tkinter
GUI library to display GPS data, with the ability to zoom and pan.
Figure 5-42 shows this application displaying a captured GPS session along
with Wi-Fi locations located using NetStumbler (a free wireless-network
sniffer for Windows). You can also use this program to display waypoints
captured on a hike, general points of interest, geocaches, and so on.
It is easy to be intimidated by mapping software, but it is really quite simple
after you master coordinate conversions. There are two coordinate planes
involved in our application: the latitude/longitude plane and the x/y pixel
plane on our GUI drawing surface. Real-world coordinates are bounded by
(–90,–180) and (90,180), whereas GUI surfaces are bounded by (0,0) and
Figure 5-42. Our sample application displaying a GPS log and Wi-Fi hotspots in the area