Wednesday, September 15, 2010

The GPS you didn't know you had

The great thing about the internet is that you can find the answer to anything. You may not understand the answer, it may not even be the correct answer, but you can find it. And sometimes you will find out more than you were expecting.

Yesterday I happened to think "If I have a computer or smartphone with a GPS, can my position be accessed from its web browser?" A quick search of Google turned up the answer that yes, it could, in newer browsers that support HTML 5 like Firefox 3.6 and Google Chrome and the Android web browser. I even found some example code showing how to use it. I made a test page to try it out for myself. The results were a little unexpected.

First I tried it using my shack PC, which is a mini-tower with only a wired connection to my router. It told me that I was in Sheffield. This was actually not unexpected, as that is similar to the location I see when visiting some blogs that have a widget to show where visitors come from. I presume they, and the web browser, use geolocation by IP address if that is the only available method, and Sheffield is presumably the location of my broadband ISP's data centre.

When I tried using my smartphone running Android I saw the GPS status icon flicker on for a couple of seconds and my page then reported my position as being in Broughton, a village a couple of miles west of here. I'm guessing that the GPS didn't have time to get a good fix so I got a poor one, or else it is reporting the location of the cell the phone is connected to.

But the really surprising result was when I tried using my laptop. This doesn't have a GPS and is connected using wi-fi to my router, so it has the same IP address on the web as the shack system. Yet my test page pinpointed my location as across the street over the back, only about 20 yards from my actual location. I tried my netbook as well and got more or less the same position . How the heck did it know where I am?

After a bit more Googling I discovered that this is done by triangulating your position using the names or SSIDs of the wi-fi access points your computer can receive. A firm called Skyhook has created a database of access points and their locations by driving around every street in every town and city in the US. There is also a site called Geomena.org that has an access point database created by ordinary individuals. You can even add to it by installing a client app in your iPhone or Android phone and going walkabout. Google has a database which it presumably created at the same time it drove around doing Street View mapping and snooping on people's unsecured data. In Firefox you can see which wi-fi geolocation database is used by going to the address about:config (no http://) and examining the value of geo.wifi.uri. By default it's Google's. You can also disable browser geolocation by changing the value of geo.enabled.

I think the geolocation feature is pretty cool but I'm sure many privacy-obsessed types will be horrified by the thought that even without an actual GPS their position can be located to that kind of accuracy.

If you are interested in trying this for yourself then you can visit the Geolocation Test page that I created. If your browser supports geolocation (and you have Javascript turned on, which is necessary for the page to work) then you will be asked if you want to share your location with g4ilo.com. This is presumably a privacy thing, because if I wanted to I could log all the positions in a database. I don't, and in any case you're all hams so I can find out where you are from qrz.com, so hopefully you won't have a problem with that. If you allow the site to see your position it will then display your latitude, longitude and Maidenhead locator and show the position on a map so you can easily see if it is accurate.

If you do try my test page I'd be interested to know, via comments, how accurate the position was and whether your computer had a GPS, wi-fi or you were using a smartphone. If you have a mobile wi-fi device, does it track your position as you move around? If the results are promising I might make a permanent page for determining your grid locator using geolocation.
Post a Comment