MOBILE

Programming the Mobile Web : Geolocation and Maps - Location Techniques

2/8/2011 4:17:00 PM
There are different techniques that we can use to determine the geographical location of a device, based on the platform, the browser, the operator, and so on. Most technologies involve server detection, but others depend on client detection, and we may even rely on the user’s input.

1. Accuracy

Every location technology has some accuracy error. This is usually specified in a distance metric, like meters or kilometers, but in some techniques accuracy is defined according to levels such as city accuracy or country accuracy.

2. Indoor Location

When we think about geolocation, we tend to think about the outside location—that is, where on the planet the user is located. Recently, there has been some interest in services that will locate a user inside a building (for example, a shopping mall or an office building). The idea is that we can offer better services for the users inside the building if we can pinpoint what floor they are on or what department they are in. These services may be local services on the Internet, or even services provided on an intranet with the user using a Wireless LAN connection.

Augmented Reality, the Promise

Augmented Reality (AR) is a very popular technology today. It involves the usage of the camera preview with additional information on the screen about the objects and places we are seeing. One of the AR solutions is geographical-based, allowing us to see, for example, the camera preview and a tag over every building and Point of Interest (POI), with more information displayed about those places.

This solution involves accelerometer, high-accuracy geolocation (e.g., GPS), digital compass, and camera support. Unfortunately, a web application cannot access all of these features from the mobile device, so we cannot create AR web applications right now. Such applications must be created as native apps, like an Objective-C application for iPhone or a Java application for Android.


3. Client Techniques

Devices support a wide variety of approaches to figuring out where they are. Different approaches may yield different results.

3.1. GPS

The Global Positioning System (GPS) is the first technique most people think of when location detection is mentioned. GPS was created by the United States government as a system for locating devices, using between 24 and 32 satellites orbiting the Earth. Many mobile devices come with a built-in GPS receiver that can read satellite data to determine location information (data must be received from a minimum of four satellites). In mobile devices, the accuracy error is between 2m and 100m. The user needs to have a sky view (outside), and it can take between 5 seconds and 5 minutes to calculate the location.

3.2. A-GPS

Assisted GPS is a software-based system available for mobile phones connected to carrier networks that can help the devices to determine their locations. The assistance can be in the form of helping the device to find a better satellite signal, or providing less-accurate information about the location of the user until the GPS has connected successfully.

In 2006, I started to use a Nokia N95 with GPS support. In my city, it took 5 minutes to get my location using GPS (with an accuracy error of 10 meters). A firmware update later added A-GPS support to the same hardware, allowing the same device in the same city to connect in 10 seconds, with an initial accuracy error of 100 meters.

3.3. Cell information

Using the operator network’s cellular towers, the carrier can triangulate the position of a mobile device. The accuracy will depend on how many cells are in range (the more densely populated your location is, the more towers will be in range and the more accurate the reading will be). The carrier knows every cell tower’s position, so it can make the calculations to detect the device’s location.

Even knowing which cell tower a device is connected to can provide an idea of its location (near the location of the tower). This might be accurate to within a block, or up to some kilometers in rural areas.

Getting the Cell Location Without the Carrier’s Assistance

It is possible to detect a mobile device’s position using cell information without the cooperation of the carrier. OpenCellID (http://www.opencellid.org) is an open source project aiming to create a complete database of cell IDs worldwide. If we can get the IDs of every cell in range and calculate the distances to those cells, we can triangulate the device’s position.

For example, Google Maps can locate even non-GPS-equipped devices anywhere in the world, and with some carrier agreements for cell detection.


3.4. WiFi Positioning System

If you have a notebook with WiFi and Google Chrome 2.0 or Firefox 3.5 or newer, go to http://maps.google.com and click on the blue circle. If you are in a large city, you will probably be located very accurately. You were just geolocated, and unless you have a 3G netbook chances are your notebook doesn’t have GPS. This technique also works on a WiFi-connected iPod Touch. But how?

The WiFi Positioning System (WPS) is a very clever technique that detects your location using the list of wireless routers that are available in your area (even if you are not connected to them). This method relies on a pre-existing database of routers and their geographical locations. Skyhook Wireless (http://skyhookwireless.com) is the leading provider, offering developer programs for most mobile and desktop platforms. Google has its own database and is the provider used by Firefox.

The main problem for us is that as yet there are no mobile browsers that give us the hotspot list.

4. Server Techniques

On the server, we can get the HTTP request headers. This is our opportunity to locate the user without using any client technology such as GPS, and in a way that works even for low-end devices.

4.1. IP address

The main server technique for locating a user is reading the client’s IP address. However, this is not as straightforward as it may sound. Depending on the user’s connection type (2G, 3G, WiFi), the IP address we receive may be the operator’s WAP gateway address, a dynamic IP address in the operator’s range, or the IP address of the WiFi connection.

To further complicate our work, we need to bear in mind proxied browsers . These browsers use a proxy server to connect to the Internet and to our servers. For example, if the user is browsing using Opera Mini, we will receive the requests from the Opera server instead of from the user’s device. Likewise, if the user has a BlackBerry device and is using a corporate Internet connection, we will receive the requests from that connection, which could be based thousands of miles from the actual user’s location.

What should we do with the IP address? There are public lists of operators’ IP addresses, and there are public and commercial solutions for determining the location of an IP address. The accuracy of this method can be country-level to city-level, although in some special situations, like when the user is using a public WiFi network, we can pinpoint the exact location.

4.2. Carrier connection

Some worldwide operators offer developer programs (both open and private) for web portals that allow any request made from a user to your web server to carry additional headers containing information about the user (e.g., identity, location, and billing services). The GSM Association, which encompasses almost all the operators around the world, has launched an initiative called OneAPI that aims to provide web applications with access to all this carrier information through its APIs.

4.3. Language

A less-accurate mechanism is to use the accepted language of the browser. If the user has set up his device correctly, it should send a header indicating the preferred language, from which we can infer the country of the user (for example, the browser may send us en-CA as the accepted language, meaning English from Canada). This results in at best country-level accuracy.

4.4. Indoor location

When users are connecting via WiFi hotspots in a single building, we can configure our routers to be queried about those users. Every WLAN user has a unique IP address in the network, so we can tell which hotspot a given user is connected to. With that information, we can identify the floor and zone where the user is located.

Nokia set up the first indoor location implementation trial in the Kamppi shopping center in Finland, shown in Figure 1. Anyone inside the shopping center can access indoor maps, information, vouchers, and even their friends’ locations by going to a website using any mobile browser from an S60 device.

Figure 1. Nokia was one of the first providers offering indoor position detection from a web browser, in a shopping center in Finland.


5. Asking the User

If you need to offer web-based location-based services, the last location mechanism available if all the others fail is to ask the user. Even if you have identified the location using another algorithm, you may be able to increase the accuracy by asking the user, as shown in Figure 2.

Figure 2. Google Local Search uses automatic geolocation if available; if not, it tries to determine your location by IP, your location history, and a search feature to define it manually.



Note:

The user may know her location, or not. For example, if the user is visiting a foreign city, she may not know her current location.


So, what should we be asking users? We should allow them to select from a closed list, or to type the location in an open text box. We can query our databases for city names, addresses, POIs (like parks, hotels, or restaurants), or zip codes. We can also query public databases using web APIs like Yahoo! PlaceMaker and Yahoo! GeoPlanet. To pinpoint the location, we can then use a geocoding query to convert the string into a latitude/longitude pair.

We should allow the users to select their current location from amongst the following:

Home

If the users need to log into the website, we can ask them where they live when they install the application and store this information in our database for future use.

Favorite places

We can make a user’s favorite places database.

History

We can allow the users to select places where they have been recently, ordering the list by frequency.

Records of all of these locations may be stored in a database on our server attached to the user’s credentials (for login-based solutions), in a cookie on the client, or even in client storage in supported devices.

Other  
  •  iPhone Programming : Table-View-Based Applications - Connecting the Controller to the Model
  •  Programming the Mobile Web : Mobilizing WordPress and Other CMSs
  •  Programming the Mobile Web : Server-Side Browser Detection and Content Delivery - Content Adaptation
  •  Programming the Mobile Web : Multimedia and Streaming
  •  Mobile Application Security : BlackBerry Security - Development and Security Testing
  •  Mobile Application Security : BlackBerry Security - Introduction to Platform
  •  Windows Phone 7 Development : Using a WebBrowser Control to Display Dynamic Content
  •  Windows Phone 7 Development : Using a WebBrowser Control to Display Local HTML Content
  •  Windows Mobile Security - Networking
  •  Windows Mobile Security - Local Data Storage
  •  Windows Mobile Security - Permissions and User Controls
  •  Windows Phone 7 Development : Using a WebBrowser Control to Display Web Content
  •  Windows Phone 7 Development : Adding a WebBrowser Control
  •  Programming the Mobile Web : Content Delivery (part 3)
  •  Programming the Mobile Web : Content Delivery (part 2) - File Delivery
  •  Programming the Mobile Web : Content Delivery (part 1) - Defining MIME Types
  •  iPhone Application Development : Using Switches, Segmented Controls, and Web Views (part 3)
  •  iPhone Application Development : Using Switches, Segmented Controls, and Web Views (part 2)
  •  iPhone Application Development : Using Switches, Segmented Controls, and Web Views (part 1)
  •  iPhone Application Development : Using Advanced Interface Objects and Views - User Input and Output
  •  
    Top 10
    Nikon 1 J2 With Stylish Design And Dependable Image And Video Quality
    Canon Powershot D20 - Super-Durable Waterproof Camera
    Fujifilm Finepix F800EXR – Another Excellent EXR
    Sony NEX-6 – The Best Compact Camera
    Teufel Cubycon 2 – An Excellent All-In-One For Films
    Dell S2740L - A Beautifully Crafted 27-inch IPS Monitor
    Philips 55PFL6007T With Fantastic Picture Quality
    Philips Gioco 278G4 – An Excellent 27-inch Screen
    Sony VPL-HW50ES – Sony’s Best Home Cinema Projector
    Windows Vista : Installing and Running Applications - Launching Applications
    Most View
    Bamboo Splash - Powerful Specs And Friendly Interface
    Powered By Windows (Part 2) - Toshiba Satellite U840 Series, Philips E248C3 MODA Lightframe Monitor & HP Envy Spectre 14
    MSI X79A-GD65 8D - Power without the Cost
    Canon EOS M With Wonderful Touchscreen Interface (Part 1)
    Windows Server 2003 : Building an Active Directory Structure (part 1) - The First Domain
    Personalize Your iPhone Case
    Speed ​​up browsing with a faster DNS
    Using and Configuring Public Folder Sharing
    Extending the Real-Time Communications Functionality of Exchange Server 2007 : Installing OCS 2007 (part 1)
    Google, privacy & you (Part 1)
    iPhone Application Development : Making Multivalue Choices with Pickers - Understanding Pickers
    Microsoft Surface With Windows RT - Truly A Unique Tablet
    Network Configuration & Troubleshooting (Part 1)
    Panasonic Lumix GH3 – The Fastest Touchscreen-Camera (Part 2)
    Programming Microsoft SQL Server 2005 : FOR XML Commands (part 3) - OPENXML Enhancements in SQL Server 2005
    Exchange Server 2010 : Track Exchange Performance (part 2) - Test the Performance Limitations in a Lab
    Extra Network Hardware Round-Up (Part 2) - NAS Drives, Media Center Extenders & Games Consoles
    Windows Server 2003 : Planning a Host Name Resolution Strategy - Understanding Name Resolution Requirements
    Google’s Data Liberation Front (Part 2)
    Datacolor SpyderLensCal (Part 1)