In my other blog I just wrote about my GPS + Google Maps Mashup.

Here are some details I left out of that entry:

Here is my PHP file for querying the Garmin GPS unit:

class GPSblob
{
	var $lat;
	var $long;
	var $timeStamp;
 
	function GPSblob($lat,$long,$timeStamp)
	{
	$this->lat=$lat;
	$this->long=$long;
	$this->timeStamp=$timeStamp;
	}
	function deltalat($lat)
	{
		return (abs($lat-$this->lat));	
	}
	function deltalong($long)
	{
		return (abs($long-$this->long));
	}
}
session_start();
include_once("xmlparser.php");
$threshold=.005;    
 
$cmd="c:\\gpsrun.bat.lnk"; 
//this is the command I'm running: 
//"gpsbabel.exe -i garmin,get_posn -f usb: -o kml -F myposition.kml"
$cmdline = "cmd /C $cmd";
$WshShell = new COM("WScript.Shell");  
$oExec = $WshShell->Run($cmdline, 0, true); 
sleep(1);
$data=file_get_contents("myposition.kml");
 
$xml = new XML_Array($data);
$xmlarray = $xml->_data; 
$parsed = split('Created ',$xmlarray[0][kml][Document][Snippet]);
$timeStamp=$parsed[1];
list($long,$lat,$delete)=
split(",",$xmlarray[0][kml][Document][Folder][Placemark][Point][coordinates]);
 
$blob=new GPSblob($lat,$long,$timeStamp);
 
if (empty($_SESSION['blob'])) 
{
   $_SESSION['blob'] = $blob;
} 
else 
{
   $previousBlob=$_SESSION['blob'];
   $deltalat = $blob->deltalat($previousBlob->lat);
   $deltalong = $blob->deltalong($previousBlob->long);
   $moved=0;
   if (($deltalat>=$threshold)||($deltalong>=$threshold))
   {
   	$moved=1;
   }
   $_SESSION['blob'] = $blob;
}
require_once('json.php');
$json = new Services_JSON();
 
$value = array($lat,$long,$timeStamp,$moved);
$output = $json->encode($value);
print($output);