GithubHelp home page GithubHelp logo

tammoippen / geohash-hilbert Goto Github PK

View Code? Open in Web Editor NEW
89.0 6.0 20.0 2.16 MB

Geohash a lng/lat coordinate using hilbert space filling curves.

License: MIT License

Python 100.00%
geohash hilbert-curve space-filling-curves geohash-representations longitude latitude

geohash-hilbert's Issues

Cython builds dropped in 1.2.1

Hi!

Thank you for this library, I've been using it for a while.

I noticed that the cython build is not triggered since 1.2.1. I'm using a clean pipenv environ in python 3.7 on a mac:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
cython = "*"

[packages]
geohash-hilbert = "==1.2.0"

[requires]
python_version = "3.7"
(hilbert) ➜  pip freeze
Cython==0.29.16
geohash-hilbert==1.2
(hilbert) ➜  python -c "from geohash_hilbert._hilbert import *; print(CYTHON_AVAILABLE)"
True
(hilbert) ➜  hilbert pipenv install geohash-hilbert==1.2.1
Installing geohash-hilbert==1.2.1…
Adding geohash-hilbert to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (6bc29a) out of date, updating to (d6a1f1)…
Locking [dev-packages] dependencies…
✔ Success!
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (6bc29a)!
Installing dependencies from Pipfile.lock (6bc29a)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:00
(hilbert) ➜  hilbert python -c "from geohash_hilbert._hilbert import *; print(CYTHON_AVAILABLE)"
False

Still missing in 1.3.1

Installing geohash-hilbert==1.3.1…
Adding geohash-hilbert to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (26ebc9) out of date, updating to (6bc29a)…
Locking [dev-packages] dependencies…
✔ Success!
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (26ebc9)!
Installing dependencies from Pipfile.lock (26ebc9)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:000:00
(hilbert) ➜  hilbert
(hilbert) ➜  hilbert python -c "from geohash_hilbert._hilbert import *; print(CYTHON_AVAILABLE)"
False

Switching back

(hilbert) ➜  hilbert pipenv install geohash-hilbert==1.2.0
Installing geohash-hilbert==1.2.0…
Adding geohash-hilbert to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (d6a1f1) out of date, updating to (26ebc9)…
Locking [dev-packages] dependencies…
✔ Success!
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (d6a1f1)!
Installing dependencies from Pipfile.lock (d6a1f1)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:00
(hilbert) ➜  hilbert python -c "from geohash_hilbert._hilbert import *; print(CYTHON_AVAILABLE)"
True

`neighbours` incorrect near poles

It looks like neighbours is incorrect at the poles: it gives the north neighbour of the north pole as the south pole. Here's an example:

In [22]: ghh.encode(0, 89.5, precision=3, bits_per_char=2)
Out[22]: '211'

In [24]: ghh.neighbours("211", bits_per_char=2)
Out[24]:
{'north': '322',
 'north-east': '323',
 'north-west': '011',
 'east': '212',
 'west': '122',
 'south': '210',
 'south-east': '213',
 'south-west': '123'}

In [25]: ghh.decode("322", bits_per_char=2)
Out[25]: (22.5, -78.75)

I guess the notion of neighboring cells is not super well defined at the poles (since all points (longitude, 90) are the same), but I would suggest that a cell which contains the north pole has no north, northwest, or northeast neighbor; likewise for the south pole and south neighbors.

If this seems good I can open a PR.

Add base32 is possible

Hi, it is a suggestion. The main geocodes, like Geohash, use something between base16 and base36 to compress, because for humans and use in resilient protocols we can use alphanumeric codes (no extra-symbols) with case insensitive letters. PlusCode e.g. uses base20, in this range. And the most useful are the base32 variants... Is important to show (here without patents, this is the merit of the open work!) how to offer Hilbert indexation of base32.

As 32×32=1024, we have an exact representation for each two base32 digits. In the Hilbert hierarchical grid terms, it is a "level L5" or "level L+5". So one digit is "L+2.5" (level L+3 minus a half)... It can be represented as "degenerated grid" merging pairs of cells:

The reindexation is necessary only when identifing the cells of the grid, and it is easy, for each cell x, of an index x starting with zero, there are a merged cell i=floor(x).

It is only a problem of spatial interpretation (grid interface construction when need), the base32 geocode existense is independent of a visual grid interface.

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.