Thursday, April 30, 2009

Location without GPS for Windows Mobile


So you are lost again- you don’t know the directions back from the down market and there is little help on the road at this hour. The town’s paper map did not live longer being subjected to daily mauling. How you wish you could have bought that smart phone with built-in GPS that tracks down all the directions, gets you details of nearest pizza vendors, helps you arrange a plumber for that leaky job and even tells you where you can go for an evening out.
But alas! It’s troubled times and you can’t afford a GPS integrated phone when it’s already tough to pay the home rent.
Detailing maps, points of interest, driving directions, and enterprise scenarios, LBS has become one of the hottest areas of mobile device development.
A large number of new generation phones have GPS built in. But the goal here is to cut cost and get the same service on phones which don’t have the built-in GPS.
We can broadly categorize Location Based services into two categories. One is a positioning technology available within carrier network system where they are able to locate the device and second GPS receiver is installed on the user’s device to get the location via satellites.
But we can also achieve it by using cell tower Information which is available on almost all the phones. It doesn’t require any GPS receiver on user device and it doesn’t require any carrier paid service for getting cell tower information. Naturally, cell tower data isn't as geo-precise as GPS. You can't tell from your cell tower data if you are 10 feet or 1000 feet from the tower, but it can still be of great help.


What we need?
We just need four key pieces of data. Cell tower ID, location area code, mobile network code and mobile country code. We need to crack open the Windows mobile Radio Interface Layer (RIL) to get cell tower data. It’s not as complex as you might think.
Windows Mobile (5 and 6) has a native API to get those four pieces of data. You can search for
RIL on MSDN for details on the entire RIL library. It’s very well documented.
We're only interested in the cell tower portion of the RIL. The first thing we need to do is import necessary methods from ril.dll to call into the radio interface layer. The methods contained in ril.dll are our gateway to cell tower data.
Once we get the cell tower data we need to translate it into latitude and longitude.
Google makes this task simple for us. We can send it off to Google via HTTP, and get back the latitude and longitude. However, Google is not the only database of tower locations. OpenCellID.org is an open source initiative to map all cell towers and their GPS coordinates. Yahoo! is doing the same thing with their ZoneTag service.

Testing your application on the computer
Testing this application is not as straight forward. This code will not directly work on your emulator. We have to configure and run cellular emulator for testing this code on developer boxes. Cellular emulator comes with Windows Mobile SDK 6.

So we got the location, now it is up to you what you do with this location. The field is wide open to come up with your own creative ideas.
Thanks for reading, and happy geo-coding!

Note: This article highlights how we can get user location based on cell tower id. If you require further details or source code you can contact me through this blog.

0 comments: