Opencellid – an alternate to GPS



OpenCellID  is a open source project,  led by 8Motions , to create a complete database of CellID worldwide, with their locations. OpenCellID collects data about the geo locations of the cell towers and use then to triangulate your position. The database is a growing entity as it also takes input about the locations from cell users. This a exciting solution for developers wanting to create location based applications without GPS.

To better understand the concept of CellId take a look at the picture given below.

cell network (taken from mobiforge.com)

All data access is available via a simple REST api found here: OpenCellID API. The api takes some simple parameters to return the lat/long information of the cell.

Parameters:

  • myapikey: Substitute here the key that you received while registering at OpenCellID.
  • mcc: the mobile country code
  • mnc: the mobile network code
  • lat: lattitude
  • lon: longitude
  • cellid: CellID
  • lac: location area code

Call can be places to the webserver like this::

<em><strong>http://www.opencellid.org/cell/get?mcc=250&amp;mnc=99&amp;cellid=29513&amp;lac=0</strong></em>

you can find a detailed explanation at mobiforge and opencellid.org. The technology is also at work on Ericsson Labs with Java ME or Android platform.  At the time of writing this there was no documented approach for Flash Lite.

On Nokia devices you can access the parameters required to make the opencellid api call, via the Nokia Platform Services.

Here is a short code snippet describing how to get those informations :

import com.nokia.lib.Service;
import mx.utils.Delegate;

var CellId;
var MNC;
var MCC;
var LAC;
var myapikey = “your api key here”;
var isValidLAC:Boolean = false;
var requestVars:XML = new XML();
var info;

// assign callback handler
requestVars.onLoad = Delegate.create(this,onInfoLoaded);

// Our first function – Obtaining the CellID

function GetCellID()
{
var sysInfo = new Service("Service.SysInfo", "ISysInfo");
var inParams = {Entity:"Network", Key:"CellID"};
sysInfo.GetInfo(inParams,onReceive);
}
// The CellID callback handler
function onReceive(transactionID:Number, eventID:String, outParam:Object)
{
if (outParam.ErrorCode == 0)
{
var systemData = outParam.ReturnValue;
CellId = systemData.Status;

/*----------- Next place call to access network info ------------*/
GetNetInfo();

}
else
{
trace("Error "+outParam.ErrorCode);
}
}

// Second function - Getting MNC , MCC, LAC
function GetNetInfo()
{
var sysInfo = new Service("Service.SysInfo", "ISysInfo");
var inParams = {Entity:"Network", Key:"CurrentNetwork"};
sysInfo.GetInfo(inParams,onNetworkInfoReceived);
}
// Network Info callback handler
function onNetworkInfoReceived(transactionID:Number, eventID:String, outParam:Object)
{
if (outParam.ErrorCode == 0)
{
var systemData = outParam.ReturnValue;
var NetInfo = systemData.NetworkInfo;
/* ------------------------------*/
MNC = NetInfo.NetworkCode;
MCC = NetInfo.CountryCode;
LAC = NetInfo.AreaCode;
isValidLAC = NetInfo.LocationStatus;
}
else
{
trace("Error "+outParam.ErrorCode);
}
}

if(( CellId != null) &amp;&amp; (isValidLAC))
{
var query =
“http://www.opencellid.org/cell/get?key=”+myapikey+”&amp;mnc=”+MNC+”&amp;mcc=”+MCC+”&amp;lac
=”+LAC+”&amp;cellid=”+ CellId;
requestVars.load(query);
}

// Callback from OpenCellId.org

function onInfoLoaded(success:Boolean)
{
if(success)
{
var status = requestVars.firstChild.attributes.stat;
if(status.toLowerCase() != “ok”)
info = “Error”;
else
{
var lat = requestVars.firstChild.firstChild.attributes.lat;
var lon = requestVars.firstChild.firstChild.attributes.lon;
var range = requestVars.firstChild.firstChild.attributes.range;
info = “Lat :”+lat+” Lon:”+lon;
}
}
else
{
info = “Error”;
}
}

// --- entry point-----
GetCellID();

Note: In case you face cross domain issues in loading data you might want to use a server side proxy solution for loading xml data.



* Please test the snippet before use on your problems.




January 20, 2010  Tags: , ,   Posted in: Flash Lite, Nokia

One Response

  1. PuckettLorrie26 - May 14, 2010

    That is cool and it opens new opportunities.

Leave a Reply