You have to be very careful when talking about location accuracy with an iPhone. Apples location services tend to have three broad levels of accuracy: cell tower, WiFi, and GPS. If you're inside, you probably won't get GPS since it needs line-of-sight with a satellite. With WiFi, if you're in an area with a handful of WiFi networks, triangulating amongst them can deliver pretty accurate location.
Apple's iOS 6 introduced the Core Location framework which we use. The framework takes full advantage of current hardware to provide a robust suite of location-based services. While trilateration or global positioning alone provides reasonable accuracy, Apple uses several techniques in unison to provide accurate location coordinates of the device. To fully appreciate the complexity of iOS location-based services, we need to understand the science and mathematics behind trilateration, assisted global positioning, and Apple's use of crowd-sourced Wi-Fi.
Trilateration - Triangulation and trilateration are two mathematical processes for determining the location of a point. Triangulation uses a process of measuring angles from known locations - such as cell towers - to calculate current position. Trilateration determines the position of a device by calculating the intersection of circles or spheres representing the distance of a device from known locations. The accuracy of these approaches is improved as more fixed locations are used in the calculations. Signal strength is used to predict the distance of a device from various cell towers. With the cell tower's fixed location known, a distance radius is established. Without the intersection of circles from a second or third cell tower position, we can only determine that the device is located somewhere on the circumference of the distance circle. An Omni-directional antenna on the cell tower can narrow down the position of a mobile device, but not close enough to satisfy most requirements. As cellular-enabled mobile devices move about, it is common - especially in densely populated areas - for the device to communicate simultaneously with several cell towers. If two cell towers are in communication with the device, we can derive two possible locations from the two intersecting points. The best case, however, is to leverage the information from at least three cell towers to pinpoint a location represented by the single intersection of three circles or spheres.
Global Navigation Systems - Global navigation systems, like GPS, provide the ability to pinpoint a device by using known coordinates of satellites as opposed to cell towers. Trilateration is used to find the intersecting point of spheres to determine the location of a GPS-enabled mobile device. GPS hardware is energy demanding, and can quickly drain the battery of a mobile device. Apple uses the more efficient Assisted Global Positioning (AGPS) process for locating and linking to satellites. With AGPS, satellite positioning is retrieved from a cellular or Wi-Fi connection reducing the amount of time it takes to discover a satellite.
Crowd-Sourcing - Apple leverages crowd-sourced information to fine tune the accuracy of location-based services on cellular and GPS enabled devices, and enable location-based services on non-cellular or Wi-Fi only devices. Crowd-sourced Wi-Fi is by far the most innovative approach for determining the location of a mobile device. Apple uses a database of Wi-Fi hotspots and cell tower locations - submitted anonymously by any number of iOS mobile devices - to help determine the coordinates of a single mobile device. Cellular, AGPS, and crowd-sourced Wi-Fi information are used to feed accurate data to iOS location-based services.
Apple iOS exposes a setting for trading off battery power and accuracy. We expose this setting in the app. We have no control over how the iPhone gets the position, we can only tell iOS to get the best fix based on the setting.