From 2594b9a19087ffcedd96125c527323ff3faaf984 Mon Sep 17 00:00:00 2001 From: lhpqaq <657407891@qq.com> Date: Thu, 4 Jul 2024 18:13:32 +0800 Subject: [PATCH] fix georadius --- database/geo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/database/geo.go b/database/geo.go index 84ab427f..89f43cc3 100644 --- a/database/geo.go +++ b/database/geo.go @@ -256,7 +256,11 @@ func geoRadius0(sortedSet *sortedset.SortedSet, lat float64, lng float64, radius upper := &sortedset.ScoreBorder{Value: float64(area[1])} elements := sortedSet.Range(lower, upper, 0, -1, true) for _, elem := range elements { - members = append(members, []byte(elem.Member)) + elemLat, elemLng := geohash.Decode(uint64(elem.Score)) + dis := geohash.Distance(lat, lng, elemLat, elemLng) + if dis <= radius { + members = append(members, []byte(elem.Member)) + } } } return protocol.MakeMultiBulkReply(members)