geohash
geohash copied to clipboard
Why -1 here ? It seems introducing some extra error
https://github.com/vinsci/geohash/blob/f31e613e1d2cf97c5e99e78dc2a88383c919b2f0/Geohash/geohash.py#L70
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