You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the excellent library, I use this library when I use python.
However, I noticed that this library and the java library have different geohash results for 0.0 points.
I looked for the specs but couldn't find them, so this is an experimental result, but it seems that only this library is different.
Perhaps the cause is that when comparing to mid, it is set to "greater than", where it should be "greater than or equal to"?
@@ -93,14 +93,14 @@ def encode(latitude, longitude, precision=12):
while len(geohash) < precision:
if even:
mid = (lon_interval[0] + lon_interval[1]) / 2
- if longitude > mid:+ if longitude >= mid:
ch |= bits[bit]
lon_interval = (mid, lon_interval[1])
else:
lon_interval = (lon_interval[0], mid)
else:
mid = (lat_interval[0] + lat_interval[1]) / 2
- if latitude > mid:+ if latitude >= mid:
ch |= bits[bit]
lat_interval = (mid, lat_interval[1])
else:
I would like to ask you to fix this if possible, but I think it is risky because of the lack of backward compatibility.
I have created two pull requests, one with the corrected code and one with another function added.
osdakira
changed the title
When encoding geohashes, there may be an error in the handling of zero points
When encoding geohashes, there may be an unexpected in the handling of zero points
Mar 24, 2023
Thanks for the excellent library, I use this library when I use python.
However, I noticed that this library and the java library have different geohash results for 0.0 points.
I looked for the specs but couldn't find them, so this is an experimental result, but it seems that only this library is different.
7zupb
ebh00
ebh00
Perhaps the cause is that when comparing to mid, it is set to "greater than", where it should be "greater than or equal to"?
I would like to ask you to fix this if possible, but I think it is risky because of the lack of backward compatibility.
I have created two pull requests, one with the corrected code and one with another function added.
Comparison with mid "greater than equal", not "greater than" by osdakira · Pull Request #18 · wdm0006/pygeohash
Add an encode_strictly function that fixes the handling of the 0 geographical location by osdakira · Pull Request #17 · wdm0006/pygeohash
The text was updated successfully, but these errors were encountered: