【问题标题】:Why do we add this code when using mmap in Google Maps API?为什么我们在 Google Maps API 中使用 mmap 时要添加此代码?
【发布时间】:2011-09-12 05:22:47
【问题描述】:
net, cid, lac = 404415, 40962, 128
import urllib

# net = MCC 404 & MNC 415

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'

我需要了解为什么我们需要将这种特定格式发送到 mmap 。特别是关于

a = '000E00000000000000000000000000001B0000000000000000000000030000'

以及为什么将 'FFFFFFFF00000000' 添加到字符串中。谁能解释一下?

【问题讨论】:

  • 您是否尝试过查看谷歌地图 API 文档?

标签: python maps


【解决方案1】:

这只是一个猜测

但我假设 a = '...' 是位置字符串,而 FFFFFF0000000 只是最后的填充,以告诉 API 这是您的请求的结束?

“a”字符串看起来如此奇怪的原因很可能是因为谷歌地图支持大量的东西,如街景、谷歌地方、图片等。所以在核心,这只是经度和纬度,但有上面有一堆额外的东西。

是的,这只是经度和纬度。 其余的只是填充。

Net、Cid 和 Lac 是 GPS 特定的值,我认为 Cid 是你的 ID(CallerID 的缩写),Lac 是本地区号,所以你可能正在为 android 做点什么?

【讨论】:

  • 以上代码返回 lat 和 long 信息作为来自 google 的响应。打印浮点(int(r[14:22],16))/1000000, 浮点(int(r[22:30],16))/1000000。所以我不认为a中的信息很长。
猜你喜欢
  • 1970-01-01
  • 2014-03-19
  • 2015-06-17
  • 1970-01-01
  • 2016-08-22
  • 1970-01-01
  • 2016-11-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多