vinsci/geohash

precision4 and 3 are the same?

Opened this issue · 0 comments

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?