google API基站定位

问题1:手机如何获得基站信息?

答:通过读串口或RIL API去获得CellID和LAC等,CellID和LAC里有基站的编号等信息。

问题2:基站信息如何定位?

答:

由于每个基站都有唯一的CID,在手机每次开机入网时,工程模式中的信息被存储在手机内存的特定区域。通过基站定位,就是通过特定的程序得到工程模式中的CID等一些参数,并通过基站地理位置的数据库,将CID与基站所在的地区相对应,最终实现移动台定位的目的。

问题3:google定位api使用?

答:

向(Secret API)http://www.google.com/glm/mmap发送http的post请求,参数CellID和LAC,从API返回基站的经纬度。

向http://www.google.com/loc/json发送http的post请求,参数为json格式。

# -*- coding: utf-8 -*-  

import os  
import sys  
import json  
import httplib  
s1='{\  
  "version": "1.1.0",\  
  "host": "maps.google.com",\  
  "access_token": "2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe",\  
  "request_address": true,\  
  "address_language": "zh_CN",\  
  "cell_towers": [\  
    {\  
      "cell_id": 11308,\  
      "location_area_code": 4269,\  
      "mobile_country_code": 460,\  
      "mobile_network_code": 0\  
    }\  
  ]\  
 }'  
class TestJSON():  
    server_url = "www.google.com"  
    def __init__(self):  
        print u"start"  
    def run(self):  
        global s1  
              
        #socket.setdefaulttimeout(10)  
        print u"Start connection"  
          
        self.conn = httplib.HTTPConnection(self.server_url)   
              
        #self.conn.set_debuglevel(5)  
                      
        request_url = "/loc/json"  
        req_headers = { "Content-Type" : "application/json" }  
                  
        req_body = s1  
          
        self.conn.request("POST", request_url, body = req_body, headers = req_headers )  
        res = self.conn.getresponse()  
        http_status = res.status  
        http_reason = res.reason  
        print res  
        msg = res.read()  
        print u"msg=", msg  
          
if __name__ == "__main__":  
    app = TestJSON()  
    app.run()  

ps:

有些防盗手机丢失后,会发一些类似"MCC:460;MNC:01;LAC:7198;CELLID:24989"内容的短信到你指定号码就是这个用途。

google map经纬度搜索API,例如http://maps.google.com/maps?q=37.771008,+-122.41175+

附件中:google location api 调用和用python封装后的google location api

猜你喜欢

转载自zhou-xingbo.iteye.com/blog/933404