ghetto GPS tracker
This is a pretty ghetto GPS tracker I threw together yesterday, having come up with the idea while I was out on my morning run. It requires: Firefox, set to open URLs from remote applications in the current window/tab, Perl, and a means of piping NMEA data from your GPS to the script’s standard input. The sleep commands are a blunt way of allowing the remote-control calls to take effect and may need to be tuned for your system/bandwidth.
#!/usr/bin/perl -w system( “firefox”, “http://maps.google.com/” ); sleep( 10 ); system( “firefox”, “javascript:var%20here=new%20GPoint(-6,53);var%20car=new%20GMarker(here);_m.map.addOverlay(car)” ); sleep( 1 ); while (<>) { next unless /GPGLL/; my ( $long, $n, $lat, $e ) = $_ =~ m/,(.*?),(.*?),(.*?),(.*?),/; ( $long, $lat ) = parseicbm( $long, $lat ); $long = -$long if $n ne “N”; $lat = -$lat if $e ne “E”; print STDERR “plotting $lat, $long\n”; system( “firefox”, “javascript:here=new%20GPoint($lat,$long);_m.map.centerAndZoom(here,4);car.point=here;car.redraw(1)” ); } sub parseicbm { my ( $lat, $long ) = @_; my ( $latdeg, $latmin ) = ( substr( $lat, 0, 2 ), substr( $lat, 2 )); $lat = $latdeg + ( $latmin / 60 ); my ( $longdeg, $longmin ) = ( substr( $long, 0, 3 ), substr( $long, 3 )); $long = $longdeg + ( $longmin / 60 ); ( $lat, $long ); }