Filip
Filip

Reputation: 605

Geohashing returns the same position for different hashes

I'm using Geohash library in python. Consider this code:

$ 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')

Why do I get the same result for different hashes? Id expect the as we have different last letter we'd get different rectangles. What am I missing?

Upvotes: 1

Views: 743

Answers (1)

flaschbier
flaschbier

Reputation: 4177

Within the given precision, the coordinates are the same for both hashes. Check

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

Compare the source for how the rounding in Geohash.decode() is calculated.

Upvotes: 2

Related Questions