thoughts scribbles images from silicon plateau
RSS icon Home icon
  • Google cell tower mapping with Python on S60

    Posted on July 11th, 2008 jebu 67 comments

    I have had my N95 for some days now. I’ll just say that the device is all I could ask for in a smart phone for, now. iPhone 3G, yeah, lets just say my take on it is clear from my choice of the N95. So the best part of this being the Python for S60 and the location API’s available via Python.

    I came across this piece of beauty which uses a hidden Google API for location detection based on cell tower information. Now what better way to start learning Python than getting this piece working on my phone with Python. I’m fed up of writing Hello Worlds to start learning a language. Here is a python version of the poor mans GPS.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    
    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

    Download
    Beware this does not work from all IP’s, from my wifi connection at home this threw an error while on the GPRS connection this worked well.

    • http://www.discount-louis-vuitton.com louis vuitton for sale

      Well , the view of the passage is totally correct ,your details is really reasonable and you guy give us new balance 1300 valuable informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!

    • http://hubpages.com/hub/800-Calorie-Diet 800 calorie diet

      Golden. Great, useful info.

    • http://www.moncler-down-jackets.com louis vuitton handbags

      I've been looking for a similar to this post. Not only extensively but also detailly. We can learn a lot from the post. moncler jackets I recommend to you , ugg boots sale you can come communication in here. Let us grow up together.On the other hand ,I know some websites content is very well.you can go and see.Such asugg boots for sale

    • http://dtvconverterboxes.blogspot.com/2009/06/magic-jack-usb-phone-jack-review-legit.html magic jack scam

      wow. This is a real treat. I'll have to try this out on my Nokia phone and see how well it works. where did you find it?

    • Zxl

      This is such a great bag and can be used for so many things. You can use it as a school bookbag, diaper bag, overnight bag, or even a travel bag
      http://www.coolcoachbags.com

    • http://www.airmax-shox.com/ nike rifts for kids

      I was looking for something like this..
      Thank you very much!!

    • http://www.fr-nike.com Nike Air Max Classic

      I’ve added a Trackback to it on my weblog

    • http://www.myshoxsneakers.com nike air max

      Its really great, this blog has got really very great stuff which helps us to growing up to our health. Keep it up the good going, It is a great pleasure to see this topic dealt with so clearly. Thanks

    • http://www.pickyourjersey.cc nfl jerseys

      Studying your surprising blog, I notice it is of the particular insights and best suited suggestions.Believe I will acquire what exactly I would like from your trusty ideas.Greatest wishes for you!

    • http://www.gd-jewelry.com แหวนแต่งงาน

      Thanks you very much. quality diamond rings. contact http://www.gd-jewelry.com

    • http://www.plioz.com modern baby toddler

      Pretty confused with your post here.

    • http://www.thonginphone.com ภาษาเกาหลี

      thank for sourc code

    • http://www.thonginphone.com ภาษาเกาหลี

      thank for souce code. http://www.thonginphone.com

    • Sharegyan011

       If you are trading in NSE, BSE, MCX and in NCDEX then let sharegyan give you all stock trading gyan

    • Sharegyan001

      If you are trading in NSE, BSE, MCX and in NCDEX then let sharegyan give you all stock trading gyan

    • Anonymous

       If you are trading in NSE, BSE, MCX and in NCDEX then let sharegyan give you all stock trading gyan

    • http://www.kizi2.com/ kizi

      Wow ! Great post .