Add Scroogle to your search area in Firefox 2.0 Install the 'Scroogle Scraper' search plugin.

March 2007


As you probably know, Microsoft released its long awaited XP successor, Vista. Some have asked what I think of it. I’ve played around with Vista a bit at work and my firm recommendation is to NOT UPGRADE TO VISTA. There is no compelling advantage. Indeed, I’m aware of many negative effects of upgrading: programs not running, device drivers not working etc.

As well, Microsoft recently released Office 2007, which contains new versions of Excel and Word. Here’s the catch: the default file format .xlsx and .docx ARE NOT BACKWARD COMPATIBLE! That is the epitome of stupidity. Purely retarded. Why would they do that?!?!?

My next desktop operating system will surely not be Vista. It will be a version of Linux. Linux has not, in my opinion, been ready for the desktop for some time, but it’s becoming better and better all the time. Stay tuned!

In my last blog entry on GPS and Google Maps, I gave the PHP source to a file that queries the USB attached GPS device, parsed the XML and returns a JSON encoded array with values containing the latitude and longitude and timestamp and if the current position has moved significantly. Now we need a webpage to call that php code and display a google map:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <script language="JavaScript" type="text/javascript" src="/js/prototype.js"></script>
  <script>
  function GetXmlHttpObject()
  {
     return Try.these(
           function() {return new XMLHttpRequest()},
           function() {return new ActiveXObject(‘Msxml2.XMLHTTP’)},
           function() {return new ActiveXObject(‘Microsoft.XMLHTTP’)}
      ) || false;
}
function queryGPSunit()
{
	document.getElementById("status").innerHTML="querying GPS…"
	var url="queryGPSunit.php"
	xmlHttp=GetXmlHttpObject()
   	if (xmlHttp==null)
   	{
   	  alert ("Browser does not support HTTP Request")
   	  return
	}
         xmlHttp.onreadystatechange=GPSreturned
         xmlHttp.open("GET",url,true)
         xmlHttp.send(null)
}
var first=1;
var long=0;
var lat=0;
var timeStamp =0;
function GPSreturned()
{
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    //alert(xmlHttp.responseText)
    eval("var decoded_data = "+xmlHttp.responseText);
    lat = decoded_data[0]
    long = decoded_data[1]
    timeStamp = decoded_data[2]
    moved = decoded_data[3]
 
    if (moved==1||first==1)
    {
     document.getElementById("currentGPS").innerHTML=lat+" "+long+" "+timeStamp
     document.getElementById("status").innerHTML="moving"
     first=0
     load(lat,long)
    }
    else
    {
    document.getElementById("status").innerHTML="paused"
    setTimeout(‘queryGPSunit()’, 4000);
    }
    }
}
  </script>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=[insert your key here]"
      type="text/javascript"></script>
    <script type="text/javascript">
 
    //<![CDATA[
 
    function load(lat,long) {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(lat,long), 16,G_HYBRID_MAP);
        var point = new GLatLng(lat,long);
        map.addOverlay(new GMarker(point));
        setTimeout(‘queryGPSunit()’, 4000);
      }
    }
 
    //]]>
    </script>
  </head>
  <body onload="queryGPSunit()" onunload="GUnload()">
  <table><tr><td>
    <div id="map" style="width: 700px; height: 500px"></div>
    </td><td>
    <b>GPS and timestamp: </b><div id="currentGPS"></div><br />
    <b>Status:</b> <div id="status"></div>
    </td>
    </tr>
    </table>
  </body>
</html>

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-&gt;lat));
	}
	function deltalong($long)
	{
		return (abs($long-$this-&gt;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-&gt;_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-&gt;deltalat($previousBlob-&gt;lat);
   $deltalong = $blob-&gt;deltalong($previousBlob-&gt;long);
   $moved=0;
   if (($deltalat&gt;=$threshold)||($deltalong&gt;=$threshold))
   {
   	$moved=1;
   }
   $_SESSION[‘blob’] = $blob;
}
require_once(‘json.php’);
$json = new Services_JSON();
 
$value = array($lat,$long,$timeStamp,$moved);
$output = $json-&gt;encode($value);
print($output);

Send to a friend * Print this page * Join the club * Talk with my robot * Advertise here * Search this Site * Donate * Link to me


Web hosting by Utah Hub *  Powered by CreativeTap *  In association with Segomo
Unless otherwise noted, Copyright 2004-2006, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah