Saturday, February 20, 2010

converting Cell ID to coordinates

You know you do not need to have a GPS capable phone in order to enjoy location based capabilities on mobile phones, thanks to Google. Since 2007, Google mobile maps can plot your location without need of GPS with some reasonable precision (sure it is using GPS if it is available). That's how, you can check your location and what is around using your mobile phone. Google is being able to find your location using its internal database of cellular antenna IDs and their locations. Google maps application on the mobile set can query this database as the it knows the ID of the cellular antenna it is talking to.

I'm not aware if that cellular tower to coordinate database is available to developers, but here basics are examplified with a code for Windows mobile platform. There are examples around in C# or PHP around, possibly based on the original reverse engineering work.

These examples are considered to work on the mobile terminal as you have the required data on the terminal. If you have access to the GSM network, you can get this data using MAP messages. Yes, you do not need Google's database if you have access to the GSM network as it means you're possibly the GSM operator's itself :)

Below is a PHP code, a mix of C# and PHP examples; letting you to query coordinates of a LAC/CID pair for any country/network. You can play with it or download the code. Though MCC/MNC is sent as parameters, it looks like the result does not depend on them. This is weird as LAC/CID pair is unique only within a certain GSM operator. I have to be making a mistake which I could not figure out :) Still, I used LAC/CID pairs for two different countries without MCC/MNC, and Google still could point the correct spot.



Related post: Drawing GSM cells on Google Maps

17 comments:

Admin said...
This comment has been removed by a blog administrator.
wlanguide said...
This comment has been removed by a blog administrator.
Bahri said...
This comment has been removed by the author.
Bahri said...
This comment has been removed by the author.
wlanguide said...
This comment has been removed by a blog administrator.
Bahri said...
This comment has been removed by the author.
wlanguide said...
This comment has been removed by a blog administrator.
Gopi Aravind said...

Hey! Very interesting adaptation of Eric's code. Super to see a live example too..

You've mentioned that with MAP messages we can get the location from the operator..do you know how to go about this..?? Cause it would lift all of GMaps' restrictions then...

Thanks a ton!

Bahri Okuroglu said...

@Gopi, Please check http://www.3gpp.org/ftp/Specs/html-info/29002.htm for ProvideSubsriberInformation message.

Nishant Mohan said...

Hi Bahri,

MCC MNC LAC CELL ID RSSI
234*10*13382*31426*-91#
234*10*13382*42392*-93#
234*10*13096*36827*-101#
234*10*13382*35107*-105#

I have this data for the positions are unavailable.

Can you help me out with the problem, Kinda stuck from long?

Bahri Okuroglu said...

When I tried the first record mcc=234 mnc=10 lac=13382 and cid=31426, the test code can find a location.

This example code does not take RSSI into account. In other words, it does not try to provide some arc with the distance estimate. I guess you have a set of CGI+RSSI and trying to perform triangulation, but this example code does not perform that.

triada said...

sevgili dostum senin php kodunu 2 ayrı php hostingde denedim ancak senin bilgilerinden başka bir değer alamıyorum sorun ne olabilir.

Bahri Okuroglu said...

Az önce bir kaç farklı LAC+CID için denedim, çalışıyordu.

Kod Google hizmetlerini kullanıyor ve Google bu mapping'i abonelerden topladıkları verilerle güncelliyor. Operatörler yeni site açtıklarında bunun Google veritabanına girmesi zaman alacaktır. Sıkıntı bu olabilir mi?

Michele (nikhes) said...

Hi, how i can include this script in html page?
I have try to put the php file into web server but it's not work! http://www.trovami.host-ed.me/laccid.php

tnx :)

Bahri Okuroglu said...

I believe you should check error logs to see if the problem with the script.

could you please try to set use_curl to false first?

$use_curl = true;

Unknown said...

Hi Bahri,

This tutorial is from year 2010, but nowadays in 2016, is still being very useful!.

As we know, Google´s cell tower database, hasn´t the exact position of the BTS (Base Station Transceiver).

For plotting a single tower location, Google takes the average signals of all measured geo-coordinates, which often turns out to be NOT VERY ACCURATE (from 50 to 1200 meters of offset).

My question is the follows,

Is there any way to resquest to the BTS and get from "it" the own coordinates?. All BTS have an inner GPS, even in GSM or LTE.

Some mobile operators use channel 50 to broadcast cell tower information. What about the coordinates of GPS´s base station?

May be used MAP messages to request the BTS?
Some operator offers Location Services (LCS), without GPS in the mobile client.

How we request and can obtain the exact location for a cell tower?

Look forward to hearing from you soon.

Best Regards.

Analia

Bahri Okuroglu said...

Dear Analia,

As you've pointed out, this data is coming from Google and it is based on data collected by Google. As far as I know there is no way to access data of operator, unless you are paying for their services.

Operators have much precise location for sure, but to be able to access to this data you need access to GSM network (like MAP message access). Some operators are providing location query services, with the approval of the queried subscribers. You may like to consult to your operator about it.

If you are an operator, everything is much easier as you will have a DB for the location of your cells. If you have access to the SS7 network, for sure you can query HLR with SRI-LCS message and then query MSC with PSL to get the location of the subscriber (in terms of an arc). Or the positioning services on the network provide much cleaner interfaces for you. Under some circumstances, GPS on the mobile handset can be queried as well, but again you will need to be some kind of GSM operator.

Regards;