I was suprised to find that seemingly none of the dedicated GPS iPhone apps could stream your current location to a computer. Therefore I knocked up this simple solution, which uses a Python script to wrap up gpsd and make it think it's connected to a real GPS receiver that outputs NMEA sentences. The receiver is of course the iPhone, which uses Javascript (to retrieve location) and basic AJAX (to send the results to the Python script) all running in Safari. The page is served from Python via WiFi or a tethered connection (Bluetooth or cable):

Tapping 'Find' will send your position to gpsd. Tapping 'Enable' will start the one-second timer and continuously repeat the process, thereby streaming your position to the computer.
The Python script launches gpsd and configures it to listen on a pseudo-terminal for NMEA sentences. It also launches the basic HTTP server that sends the above HTML page to Safari on a GET request, and sends the incoming location data (an AJAX POST) as a properly formatted NMEA sentence to the pseduo-terminal.
I have compiled gpsd for Cygwin, so at the command prompt I see:
$ python iPhone-gpsd.py GPSd running Added /dev/tty0 HTTP Server running... iPhone - - [27/Jan/2010 12:50:23] "GET / HTTP/1.1" 200 - iPhone - - [27/Jan/2010 12:50:33] "POST / HTTP/1.1" 200 - $GPRMC,125030.31,V,1234.567890,S,01234.567890,E,,,270110,,,N*5C
(The latitude and longitude values are not real in this example.)
A word of caution: Safari's timer does not tick when the phone is locked, so make sure that you temporarily disble your phone's Auto-lock while you run the page. Also, turn down the brightness to conserve battery power if you are operating wirelessly.
Another note: WiFi provides the best performance. If you want to be mobile and don't want to take your access point and power supply with you, then Internet Tethering is the other option. You will need to install a working tethering profile, which will let you connect using the white cable (this gives your phone power as well) or via Bluetooth (great for maximum mobility). The question then becomes: what is the address of the webserver to put into Safari? As iPhones support the Bluetooth PAN profile, they contain and inbuilt DHCP server that hands out addresses to connected clients. Easily enough, you just need to check what IP has been allocated to your computer (in the range 192.168.20.2 and upward). There is one drawback of using tethering though: Safari/the phone spends a long time trying to do the POST, so the update interval is extended to about five seconds. With a bit of extra hackery, position updates could be buffered and sent in a bundle, however this requires any client of gpsd to also buffer whatever data it is geotagging and then align each sample with the incoming gpsd data based on each position report's time value.
| Attachment | Size |
|---|---|
| iPhone-gpsd.zip | 5.88 KB |