mirror of
https://github.com/alicebob/miniredis.git
synced 2024-07-21 14:03:53 +08:00
9fbc4c6eae
Redis uses the simple center, which is what we do now as well.
18 lines
372 B
Go
18 lines
372 B
Go
package miniredis
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
)
|
|
|
|
func TestGeolib(t *testing.T) {
|
|
long := 13.36138933897018433
|
|
lat := 38.11555639549629859
|
|
v := toGeohash(long, lat)
|
|
equals(t, v, uint64(3479099956230698))
|
|
|
|
longBack, latBack := fromGeohash(uint64(float64(v)))
|
|
assert(t, math.Abs(long-longBack) < 0.000001, "long")
|
|
assert(t, math.Abs(lat-latBack) < 0.000001, "lat")
|
|
}
|