15

I know what the values are for MCC, MNC, LAC, & Cell ID. I want to in C write a program to calculate the position in the form of latitude and longitude values in Linux.

FYI:

Question:

  1. How can I convert MCC,MNC,LAC,Cell ID into latitude and longitude values in linux?
  2. Why does Cell ID varies every time,when trying to read?
Embedded Programmer
  • 519
  • 4
  • 8
  • 22
  • 2
    Off-topic for here, but anyway: from what I understand, you can't calculate latitude/longitude from those; you will need to look those values on some of the publicly-available databases to find location. Check: http://en.wikipedia.org/wiki/Cell_ID – Renan Sep 08 '13 at 04:42
  • I read. But do not know, how can i get location information? As we saw mobile, when enabling location information. it displays nearest BTS on screen. How can i know position based on MCC,MNC,LAC and Cell ID? – Embedded Programmer Sep 10 '13 at 03:36
  • Is there any API to do this the other way round, getting list of cells in MCC, MNC, LAC and Cell ID? – S_S Oct 26 '21 at 11:40

4 Answers4

4

To answer your questions:

  1. You can access public databases from terminal or a browser to convert cell ID to lat/lon. Databases include:

  2. Cell ID is the ID of the cell phone tower your phone/device is connected to. The moment you move a bit, or the signal of another tower nearby is better than the current one, your phone will switch over to that tower, and your Cell ID now reflects the ID of that tower.

kouton
  • 1,941
  • 2
  • 19
  • 34
  • But the "find cell" sites use 4 parameters: MMC,MNC,LAC,CID ( not only CID ), then why do they need all these values ? Is there a code which demonstrate how to find location(longitude,latitude) using these parameters ? – ransh Apr 09 '17 at 21:44
  • Please add a clear disclosure; you have to tell what relationship you have to Unwired Labs when recommending your own products. – Martijn Pieters Jun 04 '17 at 15:47
3

i wrote a python script that can do this for you. You can get a binary from the pyc file.

#!/bin/python
"""
Written by Atissonoun - Credits to MFC & HAC
***You need to initialize the script in order to fix the import and the dependency.
This is only a Beta version of the project***
This python file works as the engine for the project.
imports, coordinates, run......
"""

#Importing modules
import requests
#defining a Api_Keys

Google_API_KEY="Your google API Key goes here"
OpenCell_Api_Key ="Your OpenCellID API Key goes here"

def Google(MMC,MNC,LAC,ID,API_KEY=Google_API_KEY):
    url = "https://www.googleapis.com/geolocation/v1/geolocate?key={}".format(API_KEY)
    data={
    "radioType": "gsm",
    "cellTowers":[
        {
        "cellId": ID,
        "locationAreaCode": LAC,
        "mobileCountryCode": MMC,
        "mobileNetworkCode": MNC
        }
    ]
    }
    response = requests.post(url, json=data)
    if response.status_code == 200 :
        lat=response.json()[u'location'][u'lat']
        long = response.json()[u'location'][u'lng']
        d={'LAT':lat,'LONG':long}
        print('Located Cell: {}'.format(ID))
        return d
    else:
        print('Error: {}'.format(response.status_code))
        return None

def Opencell(MMC,MNC,LAC,ID,API_KEY=OpenCell_Api_Key):
    url = "https://us1.unwiredlabs.com/v2/process.php"
    data = {
        "token": API_KEY,
        "radio": "gsm",
        "mcc": MMC,
        "mnc": MNC,
        "cells": [{
            "lac": LAC,
            "cid": ID
        }]
    }
    response = requests.post(url, json=data)
    if response.status_code == 200:
        if response.json()[u'status']== 'error':
            print('Error: {}'.format(response.json()[u'message']))
            return None
        else:
            lat = response.json()[u'lat']
            long = response.json()[u'lon']
            d = {'LAT': lat, 'LONG': long}
            print('Located Cell: {}'.format(ID))
            return d
    else:
        print('Error: {}'.format(response.status_code))
        return None
2

You either need a database OpenCellID (they provide APIs for new cell measurement, get the position of a specific cell, etc)

or

use the "secret" API: "http://www.google.com/glm/mmap" is a non-public API to convert cellLocation to latitude and longitude.

Many ways to do that are given in the answwers for this SO question.

Community
  • 1
  • 1
Frozen Crayon
  • 5,172
  • 8
  • 36
  • 71
  • 1
    Note that [link-only answers](http://meta.stackoverflow.com/tags/link-only-answers/info) are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Oct 17 '13 at 09:01
0

You can use this simple but efficient web site that doesn't need any log in:

http://www.cell2gps.com/

while you can access to operator info like MCC and MNC to the wiki page:

http://en.wikipedia.org/wiki/Mobile_country_code#I

The result is the location GPS through Google Maps,

Rapptz
  • 20,807
  • 5
  • 72
  • 86
FBasso
  • 1
  • 1