Thursday, November 12, 2009

How the iPhone locates you?

This article is for my beloved developers - who always want to know what the truth behind the stage is.

All content in this article is based on  iPhone cookbook - a great book for iPhone developers.




Methods for positioning used in iPhone

The iPhone uses three (or possibly four) methods to locate you.These technologies including:
+ GPS Positioning
+ WiFi Positioning
+ Cell Tower Positioning
+ Internet Provider Positioning

GPS Positioning

GPS system tracks your movement courtesy of a series of medium Earth orbit satellites provided by the U.S. Department of Defense. These satellites emit microwave signals, which your iPhone picks up and uses to triangulate your position to a high level of accuracy. Like any GPS system, this requires a clear path between you and the satellites, so it works best outdoors and away from trees.

WiFi Positioning

Core Location’s preferred pseudo-GPS geopositioning method calls on Wifi-positioning service provided by SkyHook Wireless.

SkyHook offers extremely accurate WiFi placement. When an iPhone knows the WiFi and WiMax routers you are near, it uses their MAC addresses to search SkyHook’s databases, positioning you from that data.

This way provides pretty accurate positioning and can usually locate you within a few hundred feet of your actual location

Cell Tower Positioning

Currently, iPhone use cell tower positioning service through:
+ Google Maps cell tower positioning.
+ SkyHook cell tower positioning (not sure 100%).

By this way, the iPhone uses its antenna to find the nearest four or five cell towers (of the service providers) and then triangulates your position based on the cell tower signal strength. You’ve probably seen cell tower location in action; it’s the kind that shows you about a half mile away from where you are standing—assuming you’re not standing right next to an actual cell tower.

Internet Provider Positioning

This approach uses an Internet provider location to find the nearest mapped Internet provider’s central office. The returned data is typically up to several miles off your actual location—unless you happen to be visiting your Internet provider.
SkyHook actually offers a third positioning approach, but it is never seen the iPhone use.

Hybridizing the Approaches

So, what iPhone acutally works with 4 above methods?

The iPhone approaches location in stages. Based on the accuracy level you request, it uses a fallback method. If it cannot accurately locate you with GPS or SkyHook WiFi mapping, it falls back to the cell tower location of Google Maps. If that doesn’t work, it presumably falls back further to SkyHook Internet provider location. And if that doesn’t work, it finally fails. The latest releases of the SDK actually provide multiple (asynchronous!) success callbacks for each of these fallback methods. You may receive three or four results at any time.