Linux 使用 MCC、MNC、LAC 和 Cell ID 查找位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18686888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Finding location using MCC, MNC, LAC, and Cell ID
提问by Embedded Programmer
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.
我知道 MCC、MNC、LAC 和小区 ID 的值是什么。我想在 C 中编写一个程序来计算 Linux 中纬度和经度值形式的位置。
FYI:
供参考:
- MCC - Mobile Country Code
- MNC - Mobile Network Code
- LAC - Location Area Code; a 16 bit number thereby allowing 65536 location areas within one GSM PLMN
- more info is available here on Wikipedia, Location Area Identity
- MCC - 移动国家代码
- MNC - 移动网络代码
- LAC——位置区号;一个 16 位的数字,从而在一个 GSM PLMN 内允许 65536 个位置区域
- 更多信息可在 Wikipedia 上获得,Location Area Identity
Question:
题:
- How can I convert MCC,MNC,LAC,Cell ID into latitude and longitude values in linux?
- Why does Cell ID varies every time,when trying to read?
- 如何在 Linux 中将 MCC、MNC、LAC、Cell ID 转换为纬度和经度值?
- 为什么每次读取时 Cell ID 都不同?
回答by Frozen Crayon
You either need a database OpenCellID(they provide APIs for new cell measurement, get the position of a specific cell, etc)
您要么需要一个数据库 OpenCellID(它们提供用于新细胞测量的 API,获取特定细胞的位置等)
or
或者
use the "secret" API: "http://www.google.com/glm/mmap" is a non-public API to convert cellLocation to latitude and longitude.
使用“秘密”API:“ http://www.google.com/glm/mmap”是一个非公开的 API,用于将 cellLocation 转换为纬度和经度。
Many ways to do that are given in the answwers for this SO question.
回答by kouton
To answer your questions:
回答您的问题:
You can access public databases from terminal or a browser to convert cell ID to lat/lon. Databases include:
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.
您可以从终端或浏览器访问公共数据库以将单元 ID 转换为纬度/经度。数据库包括:
手机 ID 是您的手机/设备所连接的手机信号塔的 ID。当您稍微移动一点,或者附近另一座塔的信号比当前的好时,您的手机将切换到该塔,并且您的 Cell ID 现在反映了该塔的 ID。
回答by FBasso
You can use this simple but efficient web site that doesn't need any log in:
您可以使用这个不需要任何登录的简单但高效的网站:
while you can access to operator info like MCC and MNC to the wiki page:
虽然您可以通过维基页面访问运营商信息,如 MCC 和 MNC:
http://en.wikipedia.org/wiki/Mobile_country_code#I
http://en.wikipedia.org/wiki/Mobile_country_code#I
The result is the location GPS through Google Maps,
结果是通过谷歌地图定位 GPS,
回答by Ahmed chiboub
i wrote a python script that can do this for you. You can get a binary from the pyc file.
我写了一个 python 脚本,可以为你做到这一点。您可以从 pyc 文件中获取二进制文件。
#!/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