Do GPS units spit out wacky coordinates?

I’ve mentioned before that I wrote some simple code to access the GPS device in my phone and upload the coordinates to a Google Maps mashup.

This is what it was showing when I got home yesterday evening:

google map showing me somewhere in Kazakhstan

Either my minibus driving was more eventful than I remember and I took a quick detour via Kazakhstan, or there are still a couple of problems with the code…

Even after going back and removing the entry, the map still looked a little wrong:

google map showing me in the English Channel

At least the Kazakhstan update put me on land! 🙂

Actually, that last one was very nearly accurate… the longitude value was positive (1.2….) when it should have been negative (-1.2…).

I don’t think that my code to get values out of the GPS chip is that buggy… I mean, I’ve gone back and checked it fairly thoroughly, and I think I’m doing everything right. But every now and then I get some complete gibberish out of it.

I added a sanity check to the code a couple of weeks ago which discards impossible coordinates (longitude values over 180 or under -180, and latitude values over 90 or under -90) and that protects against most of the incorrect readings. Before that, I would get some very wacky values anywhere between 0 and 500,000! But it still doesn’t protect against updates which put me in the middle of a sea. 🙂

Assuming that I’m right in saying that my core code getting values out of the GPS device is fairly solid, then I guess the next step is to add something which maintains some sort of rolling average and discards values which are significantly outside of that. Should be simple, but I’m just surprised that I need to do that… is that usual?

I’ve never noticed the other GPS apps (Live Search) on my phone display such inaccurate coordinates… I wonder whether this is because they are collecting data from the GPS unit in a more reliable way than I am, or because they also have to do something like the post-coordinate-collection smoothing that I’m planning on doing?

Comments are closed.