định vị bằng cellid dựa vào database của google

Thảo luận trong 'ỨNG DỤNG DU LỊCH, BẢN ĐỒ, GPS' bắt đầu bởi bigtiger0905, 28 Tháng chín 2010.

Trạng thái chủ đề:
Không mở trả lời sau này.
  1. bigtiger0905 Thành viên

    đây là cách định vị người khác dựa vào cellID và 1 PM gián điệp (gaurdian v1.05 chẳng hạn) gởi về thông tin của tram BTS. sau đó mình sẽ dựa vào mấy cái thông tin BTS đó điền vào form để tìm toạ độ LAT LONG dựa vào DATABASE gmap của google
    hiện tại mình tìm được 1 số code python nhưng xài cái python script shell để chạy thì bị báo lỗi, mọi người xem và cùng thảo luận, cái này tương tụ VNCELLMAP nhưng VNCM là định vị của máy máy đang sử dụng còn đây là để biết được vị trí tương đối của người thân, tương tự nguoithan.net
    nhưng mình đã thấy 1 số người test và báo thành công. ai test thử rồi cho mình biết ý kiến
    Mã:
    net, cid, lac = 25002, 9164, 4000
    import urllib
    
    # net = MCC 250 & MNC 02
    
    a = '000E00000000000000000000000000001B0000000000000000000000030000'
    b = hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8)
    c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])
    [2:].zfill(8)
    string = (a + b + c + 'FFFFFFFF00000000').decode('hex')
    
    try:
        data = urllib.urlopen('http://www.google.com/glm/mmap',string)
        r = data.read().encode('hex')
        if len(r) > 14:
            print float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/
    1000000
        else:
            print 'no data in google'
    except:
        print 'connect error'
    
    Mã:
    # (c) "Neil Young" (neil.young@freenet.de)
    # 
    # This script is published under GPL (included below)
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 3 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    #
    
    from struct import *
    import httplib
    import location
    
    def req(mcc, mnc, lac, cid, attempt_short_cid):
        if cid > 65536:
            network = 5
        else:
            network = 3
        if attempt_short_cid:
            cid &= 65536    
        return pack('>BBBBBBBBBBBBBBBBBLLLHLLLLLL', 0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,mnc, mcc, network, 0, cid, lac, mnc, mcc, 0, 0)
    
    def getloc(mcc,mnc,lac,cid):
        try:
            headers = {"Content-type": "application/binary", "Connection": "close"}
            conn = httplib.HTTPConnection("www.google.com")
            body =     req(mcc, mnc, lac, cid, False)
            conn.request("POST", "/glm/mmap",  body, headers)
            resp = conn.getresponse()
            answer = resp.read()
            conn.close()
            if resp.status == 200:
                result, = unpack('>L', answer[3:7]) 
    #            if result== 0:
                result, lat, lon, hpe = unpack('>LllL', answer[3:19])
    #            print "OK", result, lat/1000000., lon/1000000., hpe
    #            else:
    #                print "ERROR", result
            else:
                print "HTTP Error "+ str(resp.status)    
            #print "Bytes sent/received: about "+str(len(body)+len(answer)+400) # 400: estimated header length
        except:
            print "Error"
        lat = lat/1000000.
        lon = lon/1000000.
    
        return result, lat, lon, hpe        
    
    (mcc, mnc, lac, cellId) = location.gsm_location()
    
    result, lat, lon, hpe = getloc(mcc, mnc, lac, cellId)
    print 'Latitude: ', lat
    print 'Longitude: ' , lon
    print 'Closing connection.\n'
    
    
    
    Mã:
    import location
    print location.gsm_location()
    MCC, MNC, LAC, CID = location.gsm_location()
    print "MCC =" + str(MCC)
    print "MNC =" + str(MNC)
    print "LAC =" + str(LAC)
    print "CID =" + str(CID)
    
    Mã:
    from httplib import HTTP
    import location
    
    latitude = 0
    longitude = 0
    
    def doLookup(cellId, lac, host = "www.google.com", port = 80):
      from string import replace
      from struct import unpack
      page = "/glm/mmap"
      http = HTTP(host, port)
      result = None
      errorCode = 0
    
      content_type, body = encode_request(cellId, lac)
      http.putrequest('POST', page)
      http.putheader('Content-Type', content_type)
      http.putheader('Content-Length', str(len(body)))
      http.endheaders()
      http.send(body)
      errcode, errmsg, headers = http.getreply()
      result = http.file.read()
      # could need some modification to get the answer: here I just need
      # to get the 5 first characters
      if (errcode == 200):
        (a, b,errorCode, latitude, longitude, c, d, e) = unpack(">hBiiiiih",result)
        latitude = latitude / 1000000.0
        longitude = longitude / 1000000.0
      return latitude, longitude
    
    def encode_request(cellId, lac):
      from struct import pack
      content_type = 'application/binary'
      body = pack('>hqh2sh13sh5sh3sBiiihiiiiii', 21, 0, 2, 'in', 13, "Nokia N95 8Gb", 5,"1.3.1", 3, "Web", 27, 0, 0, 3, 0, cellId, lac, 0, 0, 0, 0)
      return content_type, body
    
    (mcc, mnc, lac, cellId) = location.gsm_location()
    (latitude, longitude) = doLookup(cellId, lac, "www.google.com", 80)
    print latitude
    print longitude
    
    noupfix123 thích bài này.
  2. noupfix123

    noupfix123 Thành viên

    Bài viết:
    19
    Được Like:
    1
    Code không,đọc ko hiểu gì hết :D .... để ngiên cứu sao dậy ...
  3. bigtiger0905

    bigtiger0905 Thành viên

    Bài viết:
    15
    Được Like:
    3
    tui đọc cũng có hiểu gì đâu, đây là nguồn internet. code php hay gì gì còn đọc hiểu sơ sơ, còn cái python này thì pó tay.
  4. verylove

    verylove Staff Member

    Bài viết:
    5,679
    Được Like:
    2,944
    ặc , chủ topic post mà cũng ko hiểu thì làm sao ng khác hiểu đc
  5. Be Yeu

    Be Yeu Super Moderator Staff Member

    Bài viết:
    4,781
    Được Like:
    5,681
    ...... Thảo luận về cái mà mình không biết , không hiểu thì thảo luận sao được bạn ? Chủ đề đã đóng !
Trạng thái chủ đề:
Không mở trả lời sau này.