One of the coolest features of a modern smartphone is the way it can determine where you are while you're there. This has some downsides — horrible location-based ads or tracking your movements come to mind — but being able to see where you are, where you need to be, and exactly how to get there is awesome. Your smartphone is also your TomTom.

All this magic happens the same way on every phone from every company making them, regardless of the operating system. Several components work together to pinpoint you (often with an accuracy of 5 meters!) and the software can intelligently pick the best way to make it happen. If you need very precise location information for something like navigation, GPS is usually called up to do the job. The way it works is also pretty cool.

What is GPS?

Photo courtesy of the National Coordination Office for Space-Based Positioning, Navigation, and Timing.

GPS stands for Global Positioning System. It's a technology owned (yes, owned) by the U.S. government and overseen by the country's Air Force. It's free for everyone to use and primarily a North American utility even though GPS is commonly a regional name for the same sort of system in other locales.

GPS is a radio navigation system. It uses radio waves between satellites and a receiver inside your phone to provide location and time information to any software that needs to use it. You don't have to send any actual data back into space for GPS to work; you only need to be able to receive data from four or more of the 28 satellites in orbit that are dedicated for geolocation use.

GPS is precise, but it's slow and uses a lot of power on both ends.

Each satellite has its own internal atomic clock and sends a time-coded signal on a specific frequency. Your receiver chip determines which satellites are visible and unobstructed (that's important and you'll read why in a bit) then starts gathering data from the satellites with the strongest signals. GPS data is slow and this is by design — satellites run on rechargeable batteries and sending a fast signal hundreds of thousands of miles would require more power — so it'll take up to a minute to get your geolocation.

Your phone's GPS receiver uses the data from these signals to triangulate where you are and what time it is. Notice the word triangulation and the mention above that four satellites are required for GPS to work. The fourth signal is used to determine altitude so you can get your geolocation data on a map with only three signals.

GPS receivers use a lot of power and require an unobstructed view of multiple satellites to work. Obstructions can include tall buildings and that means the places where most of us live can (and does) have trouble getting the data it needs all of the time. That's where AGPS comes into the picture.

What is AGPS?

For starters, you probably use AGPS — Assisted Global Positioning System — when you want your location from your phone. As mentioned GPS radios use a lot of power and unless they stay in constant use, it can take up to a minute each and every time you get new data. Since you usually want your location while on the move, that can be a burden.

AGPS adds cellular location data to assist geolocation. Your phone carrier knows where you are since your phone "pings" cell towers. When you can see three or more towers the phone company can triangulate where you are. How precise this is will depend on the strength of the signal between your phone and the tower, but usually, it's good enough to be used for location data.

Software on your phone feeds this raw cellular location data to the GPS receiver which will periodically switch between GPS data and cellular location to get a very close approximation (within 50 meters or so) in real time. Whenever a true geolocation position is received from GPS satellites your location is adjusted; we've all seen the pin on a map indicating where we are snap into place once in a while and that's what's happening when it does.

AGPS does send data out of your phone, but its data that was already being sent when it checks for cell towers in range. you're not charged for this but you will need an active data plan to use AGPS.

Which is better?

That's an easy question: AGPS is the better solution most of the time. We want our phone to know where we are in real time, to not use a lot of battery power to do it, and to be able to refresh whenever the software needs it without waiting for a good GPS lock. AGPS location isn't as precise as a true GPS location will be, but it's good enough for almost every use case and the micro-adjustments that can be made with true GPS data when it refreshes makes up for most discrepancies.

As mentioned, AGPS needs a cellular connection. That means there are cases where GPS is preferred. Any time you have no data connection you'll be unable to use cellular-assisted GPS. The same goes when you don't have enough (three is the magic number) cell towers in range of your phone. Most apps that require location also require a data connection, but some, like Geocaching apps, live on your phone's storage and will work while you're off the beaten path looking for hidden treasure.

To get the best of both worlds, make sure you've enabled all location options in your phone's settings and let it make the decisions for you!