基于redis地理函数的简单地理库
geo_python的Python项目详细描述
地理Python
基于redis geo命令的简单地理库
- 自由软件:麻省理工学院许可证
- 文档:https://geo-python.readthedocs.io。
从3.2版开始,redis包含了一组非常棒的命令:geo命令(https://redis.io/commands#geo)
使用这些命令,我们可以轻松地开发LBS或地理应用程序。
不幸的是,这些特性不在redis py(https://github.com/andymccurdy/redis-py)发布的包中,所以我们只能使用它的开发版本。
开始
In [1]: from geo_python import Point In [2]: class MyPoint(Point): ...: __key__ = 'my_point' ...: In [3]: point = MyPoint.create(120, 40, 'my point 1') In [4]: MyPoint.query_by_pos(point.longitude, point.latitude) Out[4]: [<MyPoint __key__:my_point longitude:120.000000894 latitude:39.9999999108 member:my point 1>] In [5]: MyPoint.query_by_member(point.member) Out[5]: [<MyPoint __key__:my_point longitude:120.000000894 latitude:39.9999999108 member:my point 1>] In [6]: point.update(member='my point 2') In [7]: print point.member my point 2 In [8]: another_point = MyPoint.get_by_member(point.member) In [9]: print another_point <MyPoint __key__:my_point longitude:120.000000894 latitude:39.9999999108 member:my point 2> In [10]: print MyPoint.dist(point, another_point) 0.0 In [11]: point.geo_hash() Out[11]: 'wxj7d9v2fs0'
学分
这个包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
历史记录
0.1.0(2016-12-30)
- pypi上的第一个版本。
0.1.1(2017-01-12)
- 更改配置
0.1.2(2017-01-12)
- 修复配置错误