【问题标题】:Geohashing returns the same position for different hashesGeohashing 为不同的哈希返回相同的位置
【发布时间】:2016-03-19 21:33:48
【问题描述】:

我在 python 中使用 Geohash 库。考虑这段代码:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Geohash
>>> Geohash.decode("u3qcr")
('52.3', '21.1')
>>> Geohash.decode("u3qcx")
('52.3', '21.1')

为什么不同的哈希值会得到相同的结果?我希望我们有不同的最后一个字母,我们会得到不同的矩形。我错过了什么?

【问题讨论】:

    标签: python geohashing


    【解决方案1】:

    在给定的精度内,两个哈希的坐标相同。检查

    >>> Geohash.decode_exactly("u3qcx")
    (52.31689453125, 21.07177734375, 0.02197265625, 0.02197265625)
    >>> Geohash.decode_exactly("u3qcr")
    (52.27294921875, 21.07177734375, 0.02197265625, 0.02197265625)
    >>> 
    

    比较 the source 以了解如何计算 Geohash.decode() 中的舍入。

    【讨论】:

    • 我的输出是:(52.27294921875, 21.07177734375)(52.31689453125, 21.07177734375),所以他使用了外部库(对于 Linux:apt-get install python-geohash 没有四舍五入!)。
    • pygeohash 存在相同的函数。拯救了我的一天。谢谢。 import pygeohash exact_output = pygeohash.decode_exactly('tc0y3yc') 给出 (6.7613983154296875, 79.88365173339844, 0.0006866455078125, 0.0006866455078125)
    猜你喜欢
    • 2018-03-23
    • 2019-10-30
    • 2012-08-13
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 1970-01-01
    • 2015-09-01
    • 2014-11-30
    相关资源
    最近更新 更多