Coder Social home page Coder Social logo

vinsci / geohash Goto Github PK

View Code? Open in Web Editor NEW
347.0 10.0 104.0 200 KB

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

Python 100.00%

geohash's People

Contributors

vinsci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geohash's Issues

AGPL virality issue

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.

precision4 and 3 are the same?

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?

Why -1 here ? It seems introducing some extra error

lats = "%.*f" % (max(1, int(round(-log10(lat_err)))) - 1, lat)

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

python3.5.2 can't find the module

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.