vinsci / geohash Goto Github PK
View Code? Open in Web Editor NEWPython module to decode/encode Geohashes to/from latitude and longitude. See http://en.wikipedia.org/wiki/Geohash
License: GNU Affero General Public License v3.0
Python module to decode/encode Geohashes to/from latitude and longitude. See http://en.wikipedia.org/wiki/Geohash
License: GNU Affero General Public License v3.0
Please see patch here : https://github.com/KimaruThagna/geohash
Due to issues with using APGL in commercial software, we had to stop using this library.
Not us, but a major player about AGPL: https://opensource.google/documentation/reference/using/agpl-policy
Changing to MIT or another more permissive license could be beneficial.
NOTE: Thx for putting together this lib, it is useful
NOTE: I understand that pypi links to a fork of this, but 1. it has no issue tracking, 2. if anybody, the original author is the one to change the license.
If I run:
from geopy.distance import geodesic
base_coord_x, base_coord_y = 9.42839, 47.66578
for precision in range(12, 0, -1):
prev_dist = 0
done = False
for factor in [0.0000001, 0.00001, 0.0001, 0.001, 0.01, 0.1]:
if done:
break
for i in range(1000):
if done:
break
current_y = base_coord_y +(i * factor)
current_x = base_coord_x +(i * factor)
dist = int(geodesic((base_coord_x, base_coord_y) , (current_x, current_y)).m)
dist2 = int(geodesic((base_coord_x, base_coord_y) , (current_x, current_y)).m)
a = geohash_encode(base_coord_x, base_coord_y, precision=precision)
b = geohash_encode(base_coord_x, current_y, precision=precision)
if a != b:
print(f'geohash precision={precision:02}: {prev_dist}-{dist}m')
done = True
prev_dist = dist
I get:
geohash precision=12: 0-0m
geohash precision=11: 0-0m
geohash precision=10: 0-0m
geohash precision=09: 5-5m
geohash precision=08: 18-20m
geohash precision=07: 179-180m
geohash precision=06: 606-607m
geohash precision=05: 2306-2322m
geohash precision=04: 22754-22910m
geohash precision=03: 22754-22910m
geohash precision=02: 1326809-1328341m
geohash precision=01: 6056042-6068097m
```
What is the reason that 3 and 4 are the same?
I can import and use encode()
normally. But cannot import expand()
...
Line 70 in f31e613
For example,
hash = 'ws10q7p4'
decode hash with default method, which removes irrelevant digits per the error
pgh.decode(hash) # (22.561, 114.191)
the resulted coords actually offset a little bit from the oringinal value
pgh.encode(22.561, 114.191, 8) # ws10q7p7
here is the exact decoding result, which is called from the default method
pgh.decode_exactly(hash) # (22.560853958129883, 114.19069290161133, 8.58306884765625e-05, 0.000171661376953125)
the error is at scale of 1e-05, so I keep 4 decimal digits and try to reverse the encoding, it matches the original.
pgh.encode(22.5609, 114.1907, 8) # ws10q7p4
Can version be considered for a future update?
seems to be the problem of the capital package name
Python 3.5.2 (default, Feb 8 2017, 16:36:05)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import geohash
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'geohash'
>>> import Geohash
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.virtualenvs/mdt-test/lib/python3.5/site-packages/Geohash/__init__.py", line 21, in <module>
from geohash import decode_exactly, decode, encode
ImportError: No module named 'geohash'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.